Java Swing UI Thread Event doSwing(Runnable r)

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

Description

do Swing

License

Open Source License

Declaration

public static void doSwing(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 doSwing(Runnable r) {
        if (SwingUtilities.isEventDispatchThread()) {
            r.run();//from   w ww  . ja  va2 s .  co m
        } else {
            try {
                SwingUtilities.invokeAndWait(r);
            } catch (InvocationTargetException e) {
                throw new RuntimeException(e);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

Related

  1. doInBackground(final Runnable r)
  2. doInBackground(final Runnable runnable)
  3. doLater(final long milliseconds, final Runnable doThis)
  4. doLaterOnEventThread(Runnable task)
  5. doOnEventThreadAndWait(Runnable task)
  6. edtExecutor()
  7. edtInvokeLater(Runnable block)
  8. edtSmartInvokeAndWait(Runnable block)
  9. execute(Runnable command)