Here you can find the source of waitOnEDT(Runnable r)
public static void waitOnEDT(Runnable r)
//package com.java2s; //License from project: Apache License import javax.swing.*; import java.lang.reflect.InvocationTargetException; public class Main { public static void waitOnEDT(Runnable r) { if (SwingUtilities.isEventDispatchThread()) { r.run();/* w ww. j ava 2 s. co m*/ } else { try { SwingUtilities.invokeAndWait(r); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } } }