Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * This file is part of WebLookAndFeel library.
 *
 * WebLookAndFeel library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * WebLookAndFeel library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with WebLookAndFeel library.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.lang.reflect.InvocationTargetException;

import javax.swing.SwingUtilities;

public class Main {
    /**
     * Will invoke the specified action in EDT in case it is called from non-EDT
     * thread. It will also block any exceptions thrown by "invokeAndWait"
     * method.
     *
     * @param runnable
     *            runnable
     */
    public static void invokeAndWaitSafely(final Runnable runnable) {
        try {
            invokeAndWait(runnable);
        } catch (final Throwable e) {
            //
        }
    }

    /**
     * Will invoke the specified action in EDT in case it is called from non-EDT
     * thread.
     *
     * @param runnable
     *            runnable
     * @throws InterruptedException
     * @throws InvocationTargetException
     */
    public static void invokeAndWait(final Runnable runnable)
            throws InterruptedException, InvocationTargetException {
        if (SwingUtilities.isEventDispatchThread()) {
            runnable.run();
        } else {
            SwingUtilities.invokeAndWait(runnable);
        }
    }
}