Java Swing UI Thread Event runInSwingThread(final Runnable runnable)

Here you can find the source of runInSwingThread(final Runnable runnable)

Description

run In Swing Thread

License

Open Source License

Declaration

public static void runInSwingThread(final Runnable runnable) 

Method Source Code


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

import javax.swing.*;

import java.lang.reflect.InvocationTargetException;

public class Main {
    public static void runInSwingThread(final Runnable runnable) {
        if (SwingUtilities.isEventDispatchThread()) {
            runnable.run();// www.ja v  a 2 s.  com
        } else {
            try {
                SwingUtilities.invokeAndWait(runnable);
            } catch (final InvocationTargetException | InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

Related

  1. runInEventDispatchThread(final Runnable r)
  2. runInEventDispatchThread(Runnable r)
  3. runInEventDispatchThread(Runnable runnable)
  4. runInEventDispatchThread(Runnable runnable)
  5. runInEventDispatchThreadAndWait(final Runnable r)
  6. runInSwingThread(Runnable runnable)
  7. runLater(Runnable runnable)
  8. runLaterAndWait(final Runnable runnable)
  9. runModalProcess(String title, final Runnable runnable)