Example usage for javax.swing SwingUtilities isEventDispatchThread

List of usage examples for javax.swing SwingUtilities isEventDispatchThread

Introduction

In this page you can find the example usage for javax.swing SwingUtilities isEventDispatchThread.

Prototype

public static boolean isEventDispatchThread() 

Source Link

Document

Returns true if the current thread is an AWT event dispatching thread.

Usage

From source file:Main.java

public final static boolean isInEDT() {
    return SwingUtilities.isEventDispatchThread();
}

From source file:Main.java

public static void invokeAndWait(Runnable r) {
    if (SwingUtilities.isEventDispatchThread()) {
        r.run();/*www.j  a  va2s  . c om*/
        return;
    }
    try {
        SwingUtilities.invokeAndWait(r);
    } catch (Exception e) {
        throw new IllegalStateException("Unable to invoke/wait for task", e);
    }
}

From source file:Main.java

public static void assertInEventDispatchThread() {
    if (!SwingUtilities.isEventDispatchThread()) {
        throw new IllegalStateException("Must be called from event dispatch thread");
    }/*from w w  w .  j  a v a  2s  .co m*/
}

From source file:Main.java

public static void runOnEventQueue(Runnable r) {
    if (SwingUtilities.isEventDispatchThread()) {
        r.run();//from w w w  .ja v  a2 s . c  o  m
    } else {
        SwingUtilities.invokeLater(r);
    }
}

From source file:Main.java

public static void invokeLater(Runnable runnable) {
    if (SwingUtilities.isEventDispatchThread()) {
        runnable.run();//from  w  ww.j av a 2s.  c o  m
    } else {
        SwingUtilities.invokeLater(runnable);
    }
}

From source file:Main.java

static void invokeAndWait(Runnable task) {
    if (SwingUtilities.isEventDispatchThread()) {
        task.run();//  ww w .  j  av a  2s  .c om
    } else {
        try {
            SwingUtilities.invokeAndWait(task);
        } catch (Exception ex) {
            ex.printStackTrace();
            ex.getLocalizedMessage();
        }
    }
}

From source file:Main.java

public static void invokeInEDT(Runnable runnable) {
    if (SwingUtilities.isEventDispatchThread()) {
        runnable.run();//from  w w w  .  ja va  2  s.c  o  m
    } else {
        SwingUtilities.invokeLater(runnable);
    }
}

From source file:Main.java

public final static void assertInEDT() throws IllegalStateException {
    if (!SwingUtilities.isEventDispatchThread()) {
        throw new IllegalStateException("This code must run in the EDT");
    }//from  w ww. ja  v a 2s .  com
}

From source file:Main.java

public static void invokeAndWait(Runnable task) {
    if (SwingUtilities.isEventDispatchThread()) {
        task.run();/*from  ww w  .  j  a v a2 s . com*/
    } else {
        try {
            SwingUtilities.invokeAndWait(task);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

From source file:Main.java

static boolean isEventDispatchThread() {
    try {//from www .  ja va2  s .  co  m
        return SwingUtilities.isEventDispatchThread();
    } catch (final NullPointerException e) {
        return false;
    }
}