Java tutorial
//package com.java2s; import javax.swing.SwingUtilities; public class Main { public static void invokeInEDT(Runnable runnable) { if (SwingUtilities.isEventDispatchThread()) { runnable.run(); } else { SwingUtilities.invokeLater(runnable); } } }