List of usage examples for javax.swing SwingUtilities invokeLater
public static void invokeLater(Runnable doRun)
From source file:Main.java
private static void doSetSize(final Component component, final int width, final int height) { if (component != null && width >= 0 && height >= 0) { if (SwingUtilities.isEventDispatchThread()) { doSetSizeInEDT(component, width, height); } else {//ww w .ja v a 2 s . c om SwingUtilities.invokeLater(new Runnable() { @Override public void run() { doSetSizeInEDT(component, width, height); } }); } } }
From source file:Main.java
private static void doSetResizable(final Frame frame, final boolean isResizable) { if (frame != null) { if (SwingUtilities.isEventDispatchThread()) { doSetResizableInEDT(frame, isResizable); } else {/*from w w w . j a v a 2s.c o m*/ SwingUtilities.invokeLater(new Runnable() { @Override public void run() { doSetResizableInEDT(frame, isResizable); } }); } } }
From source file:Main.java
public static <T> T invokeAndWait(Callable<T> callable) throws TimeoutException, ExecutionException, InterruptedException { //blocks until future returns FutureTask<T> task = new FutureTask<>(callable); SwingUtilities.invokeLater(task); return task.get(); }
From source file:Main.java
private static void doSetLocation(final Component component, final int x, final int y) { if (component != null && x >= 0 && y >= 0) { if (SwingUtilities.isEventDispatchThread()) { doSetLocationInEDT(component, x, y); } else {//w w w . jav a 2s.co m SwingUtilities.invokeLater(new Runnable() { @Override public void run() { doSetLocationInEDT(component, x, y); } }); } } }
From source file:Main.java
private static void doSetTitle(final Frame frame, final String title) { if (frame != null && title != null) { if (SwingUtilities.isEventDispatchThread()) { doSetTitleInEDT(frame, title); } else {/*from ww w. jav a 2 s .c om*/ SwingUtilities.invokeLater(new Runnable() { @Override public void run() { doSetTitleInEDT(frame, title); } }); } } }
From source file:Main.java
/** * Invokes the given Runnable in the AWT event dispatching thread, not * necessarily right away. This method may be called from any thread, * including the event dispatching thread itself. * @see SwingUtilities#invokeLater(Runnable) * @param runnable the Runnable to be executed. *//*from w w w.j a v a2s . c om*/ public static void invokeLater(Runnable runnable) { if (SwingUtilities.isEventDispatchThread()) { runnable.run(); } else { SwingUtilities.invokeLater(runnable); } }
From source file:Main.java
private static void doSetText(final AbstractButton abstractButton, final String text) { if (abstractButton != null && text != null) { if (SwingUtilities.isEventDispatchThread()) { doSetTextInEDT(abstractButton, text); } else {/* ww w . ja v a2s. co m*/ SwingUtilities.invokeLater(new Runnable() { @Override public void run() { doSetTextInEDT(abstractButton, text); } }); } } }
From source file:Main.java
public static final void invokeInAWTThread(Runnable r, boolean wait) { if (SwingUtilities.isEventDispatchThread()) { r.run();/*from w w w . j av a2 s. co m*/ } else { if (wait) { try { SwingUtilities.invokeAndWait(r); } catch (Exception ex) { } } else { SwingUtilities.invokeLater(r); } } }
From source file:Main.java
private static void doPutClientProperty(final JComponent jComponent, final Object key, final Object value) { if (jComponent != null && key != null) { if (SwingUtilities.isEventDispatchThread()) { doPutClientPropertyInEDT(jComponent, key, value); } else {/*www.ja v a2s . c o m*/ SwingUtilities.invokeLater(new Runnable() { @Override public void run() { doPutClientPropertyInEDT(jComponent, key, value); } }); } } }
From source file:Main.java
/** * Similar as to {@link SwingUtilities#invokeLater(Runnable)}, but does a * check first if the current running thread is already the EDT. If so, it * will directly call the {@link Runnable#run()} method, otherwise leave it up * to {@link SwingUtilities#invokeLater(Runnable)} to invoke it on a later * moment.//w w w .j a v a2 s.com * * @param aRunnable * the runnable to call on the EDT, cannot be <code>null</code>. */ public static void invokeOnEDT(final Runnable aRunnable) { // System.out.println( "invokeOnEDT called with " + aRunnable ); if (SwingUtilities.isEventDispatchThread()) { aRunnable.run(); } else { SwingUtilities.invokeLater(aRunnable); } }