Java Swing UI Thread Event callOnGUIThread(Runnable runnable)

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

Description

call On GUI Thread

License

Apache License

Declaration

public static void callOnGUIThread(Runnable runnable) 

Method Source Code


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

import com.google.common.base.Preconditions;

import javax.swing.SwingUtilities;

public class Main {
    public static void callOnGUIThread(Runnable runnable) {
        Preconditions.checkNotNull(runnable);
        if (SwingUtilities.isEventDispatchThread()) {
            runnable.run();//w w w  . ja  v  a 2s .c o m
        } else {
            SwingUtilities.invokeLater(runnable::run);
        }
    }
}

Related

  1. assertEventDispatcherThread()
  2. assertIsEDT()
  3. assertNotEventDispatchThread()
  4. checkForEventDispatchThread()
  5. dispatchOnAWTThreadLater(Runnable r)
  6. dispatchOnAWTThreadNow(Runnable r)
  7. dispatchToEDT(Runnable runnable)