Here you can find the source of runInDispatchThread(Runnable r)
public static void runInDispatchThread(Runnable r)
//package com.java2s; //License from project: Open Source License import javax.swing.SwingUtilities; public class Main { public static void runInDispatchThread(Runnable r) { if (!SwingUtilities.isEventDispatchThread()) { try { SwingUtilities.invokeAndWait(r); } catch (Exception e) { throw new RuntimeException(e); }//from w w w . j a v a 2 s .c om } else { r.run();// If we're in the dispatch thread, run the chooser directly } } }