Java Swing UI Thread Event runInEDT(final Runnable runnable)

Here you can find the source of runInEDT(final Runnable runnable)

Description

run In EDT

License

Open Source License

Declaration

public static void runInEDT(final Runnable runnable) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *                       I N T E L   C O R P O R A T I O N
 * // w ww.  j av  a 2  s.c  o  m
 *  Functional Group: Fabric Viewer Application
 * 
 *  File Name: Util.java
 * 
 *  Archive Source: $Source$
 * 
 *  Archive Log: $Log$
 *  Archive Log: Revision 1.18  2015/08/18 14:28:35  jijunwan
 *  Archive Log: PR 130033 - Fix critical issues found by Klocwork or FindBugs
 *  Archive Log: - DateFormat is not thread safe. Changed to create new DateFormat to avoid sharing it among different threads
 *  Archive Log:
 *  Archive Log: Revision 1.17  2015/08/17 18:54:12  jijunwan
 *  Archive Log: PR 129983 - Need to change file header's copyright text to BSD license txt
 *  Archive Log: - changed frontend files' headers
 *  Archive Log:
 *  Archive Log: Revision 1.16  2015/07/28 18:29:10  fisherma
 *  Archive Log: PR 129219 - Admin page login dialog improvement
 *  Archive Log:
 *  Archive Log: Revision 1.15  2015/07/14 17:00:59  jijunwan
 *  Archive Log: PR 129541 - Should forbid save or deploy when there is invalid edit on management panel
 *  Archive Log: - removed unnecessary argument for warning message display
 *  Archive Log:
 *  Archive Log: Revision 1.14  2015/06/10 19:58:58  jijunwan
 *  Archive Log: PR 129120 - Some old files have no proper file header. They cannot record change logs.
 *  Archive Log: - wrote a tool to check and insert file header
 *  Archive Log: - applied on backend files
 *  Archive Log:
 * 
 *  Overview:
 * 
 *  @author: jijunwan
 * 
 ******************************************************************************/

import javax.swing.SwingUtilities;

public class Main {
    public static void runInEDT(final Runnable runnable) {
        if (SwingUtilities.isEventDispatchThread()) {
            runnable.run();
        } else {
            SwingUtilities.invokeLater(runnable);
        }
    }
}

Related

  1. processOnSwingEventThread(Runnable todo, boolean wait)
  2. resultOfOnEventThread(final Callable task)
  3. runAndWaitOnEDT(Runnable r)
  4. runAndWaitOnEDT(Runnable runnable)
  5. runInDispatchThread(Runnable r)
  6. runInEDT(final Supplier supplier)
  7. runInEdt(Runnable r)
  8. runInEDTAndWait(Runnable task)
  9. runInEventDispatchThread(final Runnable r)