Java Swing UI Thread Event runInEDTAndWait(Runnable task)

Here you can find the source of runInEDTAndWait(Runnable task)

Description

run In EDT And Wait

License

GNU General Public License

Declaration

public static void runInEDTAndWait(Runnable task) 

Method Source Code

//package com.java2s;
// License: GPL. For details, see LICENSE file.

import java.lang.reflect.InvocationTargetException;

import javax.swing.SwingUtilities;

public class Main {
    public static void runInEDTAndWait(Runnable task) {
        if (SwingUtilities.isEventDispatchThread()) {
            task.run();//from   w w  w.  j a v a2s .  c om
        } else {
            try {
                SwingUtilities.invokeAndWait(task);
            } catch (InterruptedException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            }
        }
    }
}

Related

  1. runAndWaitOnEDT(Runnable runnable)
  2. runInDispatchThread(Runnable r)
  3. runInEDT(final Runnable runnable)
  4. runInEDT(final Supplier supplier)
  5. runInEdt(Runnable r)
  6. runInEventDispatchThread(final Runnable r)
  7. runInEventDispatchThread(Runnable r)
  8. runInEventDispatchThread(Runnable runnable)
  9. runInEventDispatchThread(Runnable runnable)