Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import java.awt.EventQueue;
import java.lang.reflect.InvocationTargetException;

public class Main {
    /**
     * Utility method used to run, synchronously, a Runnable on the main thread. Behaves exactly
     * like {@link EventQueue#invokeAndWait(Runnable)}, but can be called from the main thread as
     * well.
     * 
     * @param runnable
     * @throws InterruptedException
     * @throws InvocationTargetException
     */
    public static void invokeAndWait(Runnable runnable) throws InvocationTargetException, InterruptedException {
        if (EventQueue.isDispatchThread()) {
            runnable.run();
        } else {
            EventQueue.invokeAndWait(runnable);
        }
    }
}