/** * ** Queues the invocation of the specified Runnable on the EventQueue, and waits for the * EventQueue ** thread to complete execution of the specified Runnable. ** @param r The Runnable * to execute */ public static void invokeAndWait(Runnable r) throws InterruptedException, InvocationTargetException { if (r != null) { // call from a child thread only! (will block otherwise) // Toolkit.getDefaultToolkit().getSystemEventQueue().invokeAndWait(r); EventQueue.invokeAndWait(r); } }