Java Swing UI Thread Event runInDispatchThread(Runnable r)

Here you can find the source of runInDispatchThread(Runnable r)

Description

run In Dispatch Thread

License

Open Source License

Declaration

public static void runInDispatchThread(Runnable r) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.SwingUtilities;

public class Main {
    public static void runInDispatchThread(Runnable r) {
        if (!SwingUtilities.isEventDispatchThread()) {
            try {
                SwingUtilities.invokeAndWait(r);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }//from  w  w  w  . j a  v a 2 s  .c om
        } else {
            r.run();// If we're in the dispatch thread, run the chooser directly
        }
    }
}

Related

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