Java Swing UI Thread Event runInEventDispatchThreadAndWait(final Runnable r)

Here you can find the source of runInEventDispatchThreadAndWait(final Runnable r)

Description

run In Event Dispatch Thread And Wait

License

Open Source License

Declaration

public static void runInEventDispatchThreadAndWait(final Runnable r) 

Method Source Code

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

import java.lang.reflect.InvocationTargetException;

import javax.swing.SwingUtilities;

public class Main {
    public static void runInEventDispatchThreadAndWait(final Runnable r) {
        if (SwingUtilities.isEventDispatchThread()) {
            r.run();//from w w w . ja  v  a  2 s . c  om
        } else {
            try {
                SwingUtilities.invokeAndWait(r);
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

Related

  1. runInEDTAndWait(Runnable task)
  2. runInEventDispatchThread(final Runnable r)
  3. runInEventDispatchThread(Runnable r)
  4. runInEventDispatchThread(Runnable runnable)
  5. runInEventDispatchThread(Runnable runnable)
  6. runInSwingThread(final Runnable runnable)
  7. runInSwingThread(Runnable runnable)
  8. runLater(Runnable runnable)
  9. runLaterAndWait(final Runnable runnable)