Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.lang.reflect.InvocationTargetException;
import javax.swing.SwingUtilities;

public class Main {

    public static void executeRunnable(Runnable runnable) {
        executeRunnable(runnable, true);
    }

    public static void executeRunnable(Runnable runnable, boolean waits) {
        if (SwingUtilities.isEventDispatchThread()) {
            runnable.run();
        } else {
            try {
                if (waits) {
                    SwingUtilities.invokeAndWait(runnable);
                } else {
                    SwingUtilities.invokeLater(runnable);
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            }
        }
    }
}