List of usage examples for javax.swing SwingUtilities isEventDispatchThread
public static boolean isEventDispatchThread()
From source file:Main.java
public static void invokeAndContiune(Runnable runnable) { if (SwingUtilities.isEventDispatchThread()) { runnable.run();/* w ww. ja va2s . c o m*/ } else { SwingUtilities.invokeLater(runnable); } }
From source file:Main.java
public static void runOnEventDispatchThread(Runnable runnable) { if (SwingUtilities.isEventDispatchThread()) { runnable.run();//w w w .j ava 2s .co m } else try { SwingUtilities.invokeAndWait(runnable); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (InvocationTargetException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } }
From source file:Main.java
public static void invokeAndWaitOrCry(final Runnable runnable) { if (SwingUtilities.isEventDispatchThread()) { runnable.run();// ww w . j a v a2 s.co m return; } try { SwingUtilities.invokeAndWait(runnable); } catch (final InterruptedException e) { throw new RuntimeException(e); } catch (final InvocationTargetException e) { throw new RuntimeException(e); } }
From source file:Main.java
public static void invokeInEDTAndWait(Runnable runnable) throws Exception { if (SwingUtilities.isEventDispatchThread()) { runnable.run();/* w w w.j a v a 2 s .c o m*/ } else { try { SwingUtilities.invokeAndWait(runnable); } catch (InvocationTargetException e) { Throwable targetException = e.getTargetException(); if (targetException instanceof Exception) throw (Exception) targetException; if (targetException instanceof Error) throw (Error) targetException; throw new IllegalStateException(targetException); } catch (InterruptedException e) { throw new IllegalStateException(e); } } }
From source file:Main.java
public static void doSwing(Runnable r) { if (SwingUtilities.isEventDispatchThread()) { r.run();/*from w ww . j a va 2s. c o m*/ } else { try { SwingUtilities.invokeAndWait(r); } catch (InvocationTargetException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); } } }
From source file:Main.java
/** * Check if on the GUI event dispatch thread. * * @return true if on the event dispatch thread */// w w w. j a va 2 s . c o m static public boolean isGUIThread() { return SwingUtilities.isEventDispatchThread(); }
From source file:Main.java
/** * Invoke and wait for the result. /*from w w w.j a v a2 s . co m*/ */ public static void invokeAndWait(Runnable runnable) { if (SwingUtilities.isEventDispatchThread()) { runnable.run(); } else { try { SwingUtilities.invokeAndWait(runnable); } catch (InterruptedException e) { throw new RuntimeException("AWT queue job interrupted."); } catch (InvocationTargetException e) { throw new RuntimeException("Unhandled exception in the AWT event queue.", e.getCause()); } } }
From source file:Main.java
public static void edtSmartInvokeAndWait(Runnable block) { if (!SwingUtilities.isEventDispatchThread()) try {//from w ww . ja v a 2s . c om SwingUtilities.invokeAndWait(block); } catch (InterruptedException e) { } catch (InvocationTargetException e) { if (e.getCause() instanceof RuntimeException) throw (RuntimeException) e.getCause(); } else block.run(); }
From source file:Main.java
/** * Throws an IllegalStateException if this thread is the Swing Event Thread. * @throws IllegalStateException if this thread is the Swing Event Thread */// w w w . j a v a2 s. co m public static void throwIfEventThread() { if (SwingUtilities.isEventDispatchThread()) throw new IllegalStateException("This method should NOT be called from the Swing Event Thread"); }
From source file:Main.java
public static void executeRunnable(Runnable runnable, boolean waits) { if (SwingUtilities.isEventDispatchThread()) { runnable.run();/*from www . ja v a 2 s.c o m*/ } else { try { if (waits) { SwingUtilities.invokeAndWait(runnable); } else { SwingUtilities.invokeLater(runnable); } } catch (InterruptedException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } }