Java Swing UI Thread Event waitOnEDT(Runnable r)

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

Description

wait On EDT

License

Apache License

Declaration

public static void waitOnEDT(Runnable r) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import javax.swing.*;
import java.lang.reflect.InvocationTargetException;

public class Main {
    public static void waitOnEDT(Runnable r) {
        if (SwingUtilities.isEventDispatchThread()) {
            r.run();/* w  ww.  j ava 2 s. co m*/
        } else {
            try {
                SwingUtilities.invokeAndWait(r);
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

Related

  1. safelyRunBlockingRoutine(Runnable runnable)
  2. safeSwingCall(@Nonnull final Runnable runnable)
  3. saveInvokeAndWait(Runnable run)
  4. throwIfNotOnEDT()
  5. toEDT(Runnable r, boolean wait)