Java Swing UI Thread Event runInSwingThread(Runnable runnable)

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

Description

run In Swing Thread

License

Apache License

Declaration

public static void runInSwingThread(Runnable runnable) 

Method Source Code

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

import javax.swing.*;

public class Main {
    public static void runInSwingThread(Runnable runnable) {
        try {/*from   ww w  .  ja  v  a2 s  .  co  m*/
            if (SwingUtilities.isEventDispatchThread()) {
                runnable.run();
            } else {
                runLater(runnable);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static void runLater(Runnable runnable) {
        SwingUtilities.invokeLater(runnable);
    }
}

Related

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