Here you can find the source of invokeEDT(final Runnable runnable)
Parameter | Description |
---|---|
runnable | runnable code dedicated to Swing |
public static void invokeEDT(final Runnable runnable)
//package com.java2s; import javax.swing.SwingUtilities; public class Main { /**/* ww w . j av a 2 s . c o m*/ * Execute the given runnable code dedicated to Swing using the Event Dispatcher Thread (EDT) * @param runnable runnable code dedicated to Swing */ public static void invokeEDT(final Runnable runnable) { if (isEDT()) { // current Thread is EDT, simply execute runnable: runnable.run(); } else { invokeLaterEDT(runnable); } } /** * Returns true if the current thread is the Event Dispatcher Thread (EDT) * * @return true if the current thread is the Event Dispatcher Thread (EDT) */ public static boolean isEDT() { return SwingUtilities.isEventDispatchThread(); } /** * Execute LATER the given runnable code dedicated to Swing using the Event Dispatcher Thread (EDT) * @param runnable runnable code dedicated to Swing */ public static void invokeLaterEDT(final Runnable runnable) { // current Thread is NOT EDT, simply invoke later runnable using EDT: SwingUtilities.invokeLater(runnable); } }