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

voidinvokeOnEventThread(Runnable r)
GUI operations should be performed only on the AWT event dispatching thread.
if (SwingUtilities.isEventDispatchThread()) {
    r.run();
} else {
    SwingUtilities.invokeAndWait(r);
voidinvokeOnEventThread(Runnable runnable)
A wrapper around invokeOnEventThread.
if (SwingUtilities.isEventDispatchThread()) {
    runnable.run();
} else {
    SwingUtilities.invokeLater(runnable);
voidisEDT()
is EDT
if (!SwingUtilities.isEventDispatchThread()) {
    throw new Error("assertion failed: not on EDT");
booleanisEDT()
Returns true if the current thread is the Event Dispatcher Thread (EDT)
return SwingUtilities.isEventDispatchThread();
booleanisEDT()
Returns TRUE if current thread is EDT.
Boolean bool;
synchronized (EDT_FLAG) {
    bool = EDT_FLAG.get();
    if (bool == null) {
        bool = SwingUtilities.isEventDispatchThread();
        EDT_FLAG.set(bool);
return bool;
booleanisEventDispatchThread()
is Event Dispatch Thread
try {
    return SwingUtilities.isEventDispatchThread();
} catch (final NullPointerException e) {
    return false;
booleanisEventDispatchThread()
Calls java.awt.EventQueue.isEventDispatchThread .
return java.awt.EventQueue.isDispatchThread();
booleanisLinefeedTag(HTML.Tag tag)
is Linefeed Tag
final List<HTML.Tag> breakers = new ArrayList<HTML.Tag>();
breakers.add(HTML.Tag.DIV);
breakers.add(HTML.Tag.H1);
breakers.add(HTML.Tag.H2);
breakers.add(HTML.Tag.H3);
breakers.add(HTML.Tag.H4);
breakers.add(HTML.Tag.H5);
breakers.add(HTML.Tag.LI);
...
voidonShowingChanged(final JComponent component, final Runnable callback)
on Showing Changed
component.addHierarchyListener(new HierarchyListener() {
    public void hierarchyChanged(final HierarchyEvent e) {
        if (e.getComponent() == component && (e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) > 0) {
            callback.run();
});
voidprocessOnSwingEventThread(Runnable todo, boolean wait)
process On Swing Event Thread
if (todo == null) {
    throw new IllegalArgumentException("Runnable == null");
if (wait) {
    if (SwingUtilities.isEventDispatchThread()) {
        todo.run();
    } else {
        try {
...