Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;

public class Main {
    /**
     * Runs a background task
     * @param r <code>Runnable</code> to execute
     * @see runTask(Runnable, boolean)
     * @see java.lang.Runnable
     * @deprecated
     */
    @Deprecated
    public static void runTask(Runnable r) {
        runTask(r, false);
    }

    /**
     * If runOnEDT is true will execute the thread on the Event Dispatch Thread
     * Otherwise it will use a SwingWorker
     * @param r <code>Runnable</code> to execute
     * @param runOnEDT run on Event Dispatching Thread
     *
     * @see javax.swing.SwingWorker
     * @see java.lang.Runnable
     * @deprecated
     */
    @Deprecated
    public static void runTask(final Runnable r, boolean runOnEDT) {
        if (runOnEDT) {
            SwingUtilities.invokeLater(r);
            return;
        }

        SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {

            @Override
            protected Void doInBackground() throws Exception {
                r.run();
                return null;
            }
        };
        worker.execute();
    }
}