Here you can find the source of runInEventDispatchThreadAndWait(final Runnable r)
public static void runInEventDispatchThreadAndWait(final Runnable r)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.InvocationTargetException; import javax.swing.SwingUtilities; public class Main { public static void runInEventDispatchThreadAndWait(final Runnable r) { if (SwingUtilities.isEventDispatchThread()) { r.run();//from w w w . ja v a 2 s . c om } else { try { SwingUtilities.invokeAndWait(r); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } } }