Here you can find the source of dispatchOnAWTThreadLater(Runnable r)
public static void dispatchOnAWTThreadLater(Runnable r)
//package com.java2s; /*------------------------------------------------------------------ * Copyright (c) 2014 Cisco Systems//from w w w . j a va2s. c om * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *------------------------------------------------------------------*/ import javax.swing.SwingUtilities; public class Main { public static void dispatchOnAWTThreadLater(Runnable r) { if (SwingUtilities.isEventDispatchThread()) { r.run(); } else { SwingUtilities.invokeLater(r); } } }