Here you can find the source of dispatchOnAWTThreadNow(Runnable r)
public static void dispatchOnAWTThreadNow(Runnable r)
//package com.java2s; /*------------------------------------------------------------------ * Copyright (c) 2014 Cisco Systems/*from w w w . j a va 2 s .c o m*/ * 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 java.lang.reflect.InvocationTargetException; import javax.swing.SwingUtilities; public class Main { public static void dispatchOnAWTThreadNow(Runnable r) { if (SwingUtilities.isEventDispatchThread()) r.run(); else try { SwingUtilities.invokeAndWait(r); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }