Java Swing UI Thread Event runAndWaitOnEDT(Runnable r)

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

Description

run And Wait On EDT

License

LGPL

Declaration

public static void runAndWaitOnEDT(Runnable r) throws InterruptedException 

Method Source Code


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

import java.awt.EventQueue;
import java.lang.reflect.InvocationTargetException;

import javax.swing.SwingUtilities;

public class Main {
    public static void runAndWaitOnEDT(Runnable r) throws InterruptedException {
        if (EventQueue.isDispatchThread()) {
            r.run();//from  w w w  .ja v a2  s .co m
        } else {
            try {
                SwingUtilities.invokeAndWait(r);
            } catch (InvocationTargetException e) {
                e.printStackTrace(); //TODO: handle this better
            }
        }
    }
}

Related

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