List of utility methods to do Swing UI Thread Event
void | invokeAndWaitEDT(final Runnable runnable) Execute the given runnable code dedicated to Swing using the Event Dispatcher Thread (EDT) And waits for completion if (isEDT()) { runnable.run(); } else { if (Thread.currentThread().isInterrupted()) { invokeLaterEDT(runnable); } else { try { SwingUtilities.invokeAndWait(runnable); ... |
void | invokeAndWaitFromAnyThread(Runnable r) In EDT just runs the runnable (so in that thread the pending AWT events are _not_ dispatched before running the runnable). if (SwingUtilities.isEventDispatchThread()) { try { r.run(); } catch (RuntimeException e) { throw new InvocationTargetException(e); } else { SwingUtilities.invokeAndWait(r); ... |
void | invokeAndWaitSafely(final Runnable runnable) Will invoke the specified action in EDT in case it is called from non-EDT thread. try { invokeAndWait(runnable); } catch (final Throwable e) { |
void | invokeAndWaitUnchecked(Runnable runnable) SwingUtilities.invokeAndWait exceptions rethrown as unchecked RuntimeExceptions. try { SwingUtilities.invokeAndWait(runnable); } catch (Exception e) { throw new RuntimeException("Cannot wait for invokeAndWait", e); |
void | invokeEDT(final Runnable runnable) Execute the given runnable code dedicated to Swing using the Event Dispatcher Thread (EDT) if (isEDT()) { runnable.run(); } else { invokeLaterEDT(runnable); |
void | invokeInAWTThread(Runnable r) invoke In AWT Thread invokeInAWTThread(r, false); |
void | invokeInEventDispatchThread(@Nonnull Runnable runnable) Invokes the runnable within the EDT if (isEventDispatchThread()) { runnable.run(); } else { try { SwingUtilities.invokeAndWait(runnable); } catch (InterruptedException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { ... |
void | invokeInSwingThread(Runnable r) invoke In Swing Thread if (EventQueue.isDispatchThread()) { r.run(); } else { try { SwingUtilities.invokeAndWait(r); } catch (Exception ex) { throw new RuntimeException(ex); |
void | invokeLater(final Runnable r) invoke Later if (SwingUtilities.isEventDispatchThread()) { r.run(); } else { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { r.run(); }); |
void | invokeLater(Runnable runnable, boolean forceLater) Invoke "runnable" on the AWT event dispatching thread. If you are in the AWT event dispatching thread the runnable can be executed immediately depending the value of forceLater parameter.
if (SwingUtilities.isEventDispatchThread() && !forceLater) runnable.run(); else SwingUtilities.invokeLater(runnable); |