Here you can find the source of doSwing(Runnable r)
public static void doSwing(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 doSwing(Runnable r) { if (SwingUtilities.isEventDispatchThread()) { r.run();//from w ww . ja va2 s . co m } else { try { SwingUtilities.invokeAndWait(r); } catch (InvocationTargetException e) { throw new RuntimeException(e); } catch (InterruptedException e) { throw new RuntimeException(e); } } } }