Here you can find the source of runOnSwingThread(Runnable doRun)
Parameter | Description |
---|---|
doRun | The doRun run run (the doRun run). |
public static void runOnSwingThread(Runnable doRun)
//package com.java2s; //License from project: Open Source License import javax.swing.SwingUtilities; public class Main { /**//from w w w .j a va 2 s .c o m * Runs the given Runnable on the Swing event dispatch thread. If the * calling thread <i>is</i> the event dispatch thread, doRun is run * immediately (before this method returns). Otherwise, doRun is appended to * the end of the Swing event queue. * <p> * This method should be particularly handy in event handler code that has * to deal with the possibility that an event is being received on a thread * other than the Swing event dispatch thread. * * @param doRun * The doRun run run (the doRun run). */ public static void runOnSwingThread(Runnable doRun) { if (SwingUtilities.isEventDispatchThread()) { doRun.run(); } else { SwingUtilities.invokeLater(doRun); } } }