Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.awt.EventQueue;

public class Main {
    /**
     * Causes <code>runnable</code> to have its <code>run</code> method called
     * in the dispatch thread of {@link Toolkit#getSystemEventQueue the system
     * EventQueue} if this method is not being called from it. This will happen
     * after all pending events are processed.
     * 
     * @param runnable
     *            the <code>Runnable</code> whose <code>run</code> method should
     *            be executed synchronously on the <code>EventQueue</code>
     */
    public static void invokeOnEdt(Runnable runnable) {
        boolean isEdt = EventQueue.isDispatchThread();
        if (!isEdt) {
            EventQueue.invokeLater(runnable);
        } else {
            runnable.run();
        }
    }
}