
package uk.co.wingpath.event;

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


/**
* A collection of utility methods for event handling.
*/

public class Event
{
    private Event ()
    {
    }

    /**
    * Checks that the calling thread is the AWT event dispatch thread,
    * and throws an exception if not.
    * @throws IllegalStateException if calling thread is not the event
    *   dispatch thread.
    */
    public static void checkIsEventDispatchThread ()
    {
        if (!EventQueue.isDispatchThread ())
            throw new IllegalStateException ("Not event dispatch thread");
    }

    /**
    * Checks that the calling thread is NOT the AWT event dispatch thread,
    * and throws an exception if it is.
    * @throws IllegalStateException if calling thread is the event
    *   dispatch thread.
    */
    public static void checkIsNotEventDispatchThread ()
    {
        if (EventQueue.isDispatchThread ())
            throw new IllegalStateException ("Is event dispatch thread");
    }
}

