Here you can find the source of runInSwingThread(Runnable runnable)
public static void runInSwingThread(Runnable runnable)
//package com.java2s; //License from project: Apache License import javax.swing.*; public class Main { public static void runInSwingThread(Runnable runnable) { try {/*from ww w . ja v a2 s . co m*/ if (SwingUtilities.isEventDispatchThread()) { runnable.run(); } else { runLater(runnable); } } catch (Exception e) { throw new RuntimeException(e); } } public static void runLater(Runnable runnable) { SwingUtilities.invokeLater(runnable); } }