Java tutorial
//package com.java2s; import javax.swing.SwingUtilities; public class Main { /** * Throws an IllegalStateException if this thread is the Swing Event Thread. * @throws IllegalStateException if this thread is the Swing Event Thread */ public static void throwIfEventThread() { if (SwingUtilities.isEventDispatchThread()) throw new IllegalStateException("This method should NOT be called from the Swing Event Thread"); } }