Java Utililty Methods Swing UI Thread Event

List of utility methods to do Swing UI Thread Event

Description

The list of methods to do Swing UI Thread Event are organized into topic(s).

Method

ThreaddoLater(final long milliseconds, final Runnable doThis)
Schedule something to occur at some specified point in the future in the Swing Event thread.
Thread thread = new Thread(new Runnable() {
    public void run() {
        try {
            Thread.sleep(milliseconds);
            SwingUtilities.invokeAndWait(doThis);
        } catch (InterruptedException e) {
             } catch (java.lang.reflect.InvocationTargetException e) {
});
thread.start();
return thread;
voiddoLaterOnEventThread(Runnable task)
Schedule a task for later execution on the even dispatch thread and return immediately.
SwingUtilities.invokeLater(task);
voiddoOnEventThreadAndWait(Runnable task)
Execute a task on the even dispatch thread and wait for it to finish.
if (SwingUtilities.isEventDispatchThread()) {
    task.run();
} else {
    try {
        SwingUtilities.invokeAndWait(task);
    } catch (InterruptedException e) {
        throw new RuntimeException(
                "Thread interrupted while waiting for task to execute on event dispatch thread", e);
...
voiddoSwing(Runnable r)
do Swing
if (SwingUtilities.isEventDispatchThread()) {
    r.run();
} else {
    try {
        SwingUtilities.invokeAndWait(r);
    } catch (InvocationTargetException e) {
        throw new RuntimeException(e);
    } catch (InterruptedException e) {
...
ExecutoredtExecutor()
edt Executor
return EDT_EXECUTOR;
voidedtInvokeLater(Runnable block)
edt Invoke Later
SwingUtilities.invokeLater(block);
voidedtSmartInvokeAndWait(Runnable block)
edt Smart Invoke And Wait
if (!SwingUtilities.isEventDispatchThread())
    try {
        SwingUtilities.invokeAndWait(block);
    } catch (InterruptedException e) {
    } catch (InvocationTargetException e) {
else
    block.run();
...
voidexecute(Runnable command)
Sends a Runnable to the EDT for the execution.
SwingUtilities.invokeLater(command);
voidexecuteInSwingThread(final Runnable code)
Execute code in swing thread only.
if (SwingUtilities.isEventDispatchThread()) {
    code.run();
} else {
    SwingUtilities.invokeLater(code);
voidexecuteRunnable(Runnable runnable)
execute Runnable
executeRunnable(runnable, true);