Java Swing UI Thread Event invokeOnEventThread(Runnable runnable)

Here you can find the source of invokeOnEventThread(Runnable runnable)

Description

A wrapper around invokeOnEventThread.

License

LGPL

Parameter

Parameter Description
runnable a parameter

Declaration

public static void invokeOnEventThread(Runnable runnable) 

Method Source Code

//package com.java2s;
/*/*from ww w .  j  a  va  2 s . c om*/
 * Copyright (c) 2007-2012 The Broad Institute, Inc.
 * SOFTWARE COPYRIGHT NOTICE
 * This software and its documentation are the copyright of the Broad Institute, Inc. All rights are reserved.
 *
 * This software is supplied without any warranty or guaranteed support whatsoever. The Broad Institute is not responsible for its use, misuse, or functionality.
 *
 * This software is licensed under the terms of the GNU Lesser General Public License (LGPL),
 * Version 2.1 which is available at http://www.opensource.org/licenses/lgpl-2.1.php.
 */

import javax.swing.*;

public class Main {
    /**
     * A wrapper around invokeOnEventThread.  If the runnable is already in the event dispatching
     * queue it is just run.  Otherwise it is placed in the queue via invokeOnEventThread.
     * <p/>
     * I'm not sure this is strictly necessary,  but is safe.
     *
     * @param runnable
     */
    public static void invokeOnEventThread(Runnable runnable) {
        if (SwingUtilities.isEventDispatchThread()) {
            runnable.run();
        } else {
            SwingUtilities.invokeLater(runnable);
        }
    }
}

Related

  1. invokeOnEDT(final Runnable aRunnable)
  2. invokeOnEventDispatchThread(Runnable r)
  3. invokeOnEventDispatchThreadIfRequired(final Runnable runnable)
  4. invokeOnEventThread(Runnable r)
  5. invokeOnEventThread(Runnable r)
  6. isEDT()
  7. isEDT()
  8. isEDT()
  9. isEventDispatchThread()