Here you can find the source of runAndWaitOnEDT(Runnable r)
public static void runAndWaitOnEDT(Runnable r) throws InterruptedException
//package com.java2s; //License from project: LGPL import java.awt.EventQueue; import java.lang.reflect.InvocationTargetException; import javax.swing.SwingUtilities; public class Main { public static void runAndWaitOnEDT(Runnable r) throws InterruptedException { if (EventQueue.isDispatchThread()) { r.run();//from w w w .ja v a2 s .co m } else { try { SwingUtilities.invokeAndWait(r); } catch (InvocationTargetException e) { e.printStackTrace(); //TODO: handle this better } } } }