Here you can find the source of runInSwingThread(final Runnable runnable)
public static void runInSwingThread(final Runnable runnable)
//package com.java2s; //License from project: Open Source License import javax.swing.*; import java.lang.reflect.InvocationTargetException; public class Main { public static void runInSwingThread(final Runnable runnable) { if (SwingUtilities.isEventDispatchThread()) { runnable.run();// www.ja v a 2 s. com } else { try { SwingUtilities.invokeAndWait(runnable); } catch (final InvocationTargetException | InterruptedException e) { throw new RuntimeException(e); } } } }