List of usage examples for javax.swing SwingUtilities isEventDispatchThread
public static boolean isEventDispatchThread()
From source file:Main.java
/** * Invoke "runnable" on the AWT event dispatching thread.<br> * If you are in the AWT event dispatching thread the runnable can be executed immediately<br> * depending the value of <code>forceLater</code> parameter. * /*from w ww. j a v a 2 s. com*/ * @param forceLater * Force execution of runnable to be delayed<br> * even if we are on the AWT event dispatching thread */ public static void invokeLater(Runnable runnable, boolean forceLater) { if (SwingUtilities.isEventDispatchThread() && !forceLater) runnable.run(); else SwingUtilities.invokeLater(runnable); }
From source file:Main.java
/** * Will invoke the specified action in EDT in case it is called from non-EDT * thread./*from w w w . j a va2s. c o m*/ * * @param runnable * runnable * @throws InterruptedException * @throws InvocationTargetException */ public static void invokeAndWait(final Runnable runnable) throws InterruptedException, InvocationTargetException { if (SwingUtilities.isEventDispatchThread()) { runnable.run(); } else { SwingUtilities.invokeAndWait(runnable); } }
From source file:de.codesourcery.eve.skills.util.Misc.java
public static void runOnEventThread(Runnable r) { if (SwingUtilities.isEventDispatchThread()) { r.run();/* w ww. j a va2s . c o m*/ } else { try { SwingUtilities.invokeAndWait(r); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (InvocationTargetException e) { throw new RuntimeException(e); } } }
From source file:Main.java
private static void doSetIgnoreRepaint(final Component component, final boolean ignoreRepaint) { if (component != null) { if (SwingUtilities.isEventDispatchThread()) { doSetIgnoreRepaintInEDT(component, ignoreRepaint); } else {//from w w w .ja va 2 s. c om SwingUtilities.invokeLater(new Runnable() { @Override public void run() { doSetIgnoreRepaintInEDT(component, ignoreRepaint); } }); } } }
From source file:Main.java
/** * Returns true if the current thread is the Event Dispatcher Thread (EDT) * * @return true if the current thread is the Event Dispatcher Thread (EDT) *//*ww w.j a va2 s . c om*/ public static boolean isEDT() { return SwingUtilities.isEventDispatchThread(); }
From source file:painting.SwingPaintDemo1.java
private static void createAndShowGUI() { System.out.println("Created GUI on EDT? " + SwingUtilities.isEventDispatchThread()); JFrame f = new JFrame("Swing Paint Demo"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(250, 250);/*from w ww . jav a 2s .co m*/ f.setVisible(true); }
From source file:Main.java
/** * <p>isEventDispatchThread</p> * * @return a boolean.// www.j a v a2 s . co m */ public static boolean isEventDispatchThread() { return SwingUtilities.isEventDispatchThread(); }
From source file:GUIUtils.java
public static void processOnSwingEventThread(Runnable todo, boolean wait) { if (todo == null) { throw new IllegalArgumentException("Runnable == null"); }//ww w.j a va2s . c o m if (wait) { if (SwingUtilities.isEventDispatchThread()) { todo.run(); } else { try { SwingUtilities.invokeAndWait(todo); } catch (Exception ex) { throw new RuntimeException(ex); } } } else { if (SwingUtilities.isEventDispatchThread()) { todo.run(); } else { SwingUtilities.invokeLater(todo); } } }
From source file:Main.java
/** * Execute {@code doRun} in the EDT. The calling thread does NOT wait for * the completion of {@code doRun}.//from w w w . ja v a 2s . c o m * * This method use internally * {@link javax.swing.SwingUtilities#invokeLater(Runnable)}, so any * exception thrown during the execution of {@code doRun} is caught in the * EDT. * * @param doRun * {@code Runnable} to be run. * */ public static void invokeLater(Runnable doRun) { if (SwingUtilities.isEventDispatchThread()) { doRun.run(); } else { SwingUtilities.invokeLater(doRun); } }
From source file:painting.SwingPaintDemo2.java
private static void createAndShowGUI() { System.out.println("Created GUI on EDT? " + SwingUtilities.isEventDispatchThread()); JFrame f = new JFrame("Swing Paint Demo"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new MyPanel()); f.pack();/*from w ww .jav a2s . co m*/ f.setVisible(true); }