FileDocCategorySizeDatePackage
EventQueue.javaAPI DocAndroid 1.5 API9177Wed May 06 22:41:54 BST 2009java.awt

EventQueue

public class EventQueue extends Object
The EventQueue class manages events. It is a platform-independent class that queues events both from the underlying peer classes and from trusted application classes.
since
Android 1.0

Fields Summary
private final EventQueueCoreAtomicReference
coreRef
The core ref.
Constructors Summary
EventQueue(Toolkit t)
Instantiates a new event queue.

param
t the t.

        setCore(new EventQueueCore(this, t));
    
public EventQueue()
Instantiates a new event queue.

        setCore(new EventQueueCore(this));
    
Methods Summary
protected voiddispatchEvent(java.awt.AWTEvent event)
Dispatches the specified event.

param
event the AWTEvent.

        getCore().dispatchEventImpl(event);
    
EventQueueCoregetCore()
Gets the core.

return
the core.

        return coreRef.get();
    
public static java.awt.AWTEventgetCurrentEvent()
Returns the the currently dispatched event by the EventQueue associated with the calling thread.

return
the currently dispatched event or null if this method is invoked from a thread other than an event-dispatching thread.

        EventQueue eq = getSystemEventQueue();
        return (eq != null) ? eq.getCurrentEventImpl() : null;
    
private java.awt.AWTEventgetCurrentEventImpl()
Gets the current event impl.

return
the current event impl.

        return getCore().getCurrentEvent();
    
public static longgetMostRecentEventTime()
Gets the most recent event's timestamp. This event was dispatched from the EventQueue associated with the calling thread.

return
the timestamp of the last Event to be dispatched, or System.currentTimeMillis() if this method is invoked from a thread other than an event-dispatching thread.

        EventQueue eq = getSystemEventQueue();
        return (eq != null) ? eq.getMostRecentEventTimeImpl() : System.currentTimeMillis();
    
private longgetMostRecentEventTimeImpl()
Gets the most recent event time impl.

return
the most recent event time impl.

        return getCore().getMostRecentEventTime();
    
public java.awt.AWTEventgetNextEvent()
Returns an event from the EventQueue and removes it from this queue.

return
the next AWTEvent.
throws
InterruptedException is thrown if another thread interrupts this thread.

        return getCore().getNextEvent();
    
java.awt.AWTEventgetNextEventNoWait()
Gets the next event no wait.

return
the next event no wait.

        return getCore().getNextEventNoWait();
    
private static java.awt.EventQueuegetSystemEventQueue()
Gets the system event queue.

return
the system event queue.

        Thread th = Thread.currentThread();
        if (th instanceof EventDispatchThread) {
            return ((EventDispatchThread)th).toolkit.getSystemEventQueueImpl();
        }
        return null;
    
public static voidinvokeAndWait(java.lang.Runnable runnable)
Posts an InvocationEvent which executes the run() method on a Runnable when dispatched by the AWT event dispatcher thread and the notifyAll method is called on it immediately after run returns.

param
runnable the Runnable whose run method should be executed synchronously on the EventQueue.
throws
InterruptedException if another thread has interrupted this thread.
throws
InvocationTargetException if an error occurred while running the runnable.


        if (isDispatchThread()) {
            throw new Error();
        }

        final Toolkit toolkit = Toolkit.getDefaultToolkit();
        final Object notifier = new Object(); // $NON-LOCK-1$
        InvocationEvent event = new InvocationEvent(toolkit, runnable, notifier, true);

        synchronized (notifier) {
            toolkit.getSystemEventQueueImpl().postEvent(event);
            notifier.wait();
        }

        Exception exception = event.getException();

        if (exception != null) {
            throw new InvocationTargetException(exception);
        }
    
public static voidinvokeLater(java.lang.Runnable runnable)
Posts an InvocationEvent which executes the run() method on a Runnable when dispatched by the AWT event dispatcher thread.

param
runnable the Runnable whose run method should be executed synchronously on the EventQueue.

        Toolkit toolkit = Toolkit.getDefaultToolkit();
        InvocationEvent event = new InvocationEvent(toolkit, runnable);
        toolkit.getSystemEventQueueImpl().postEvent(event);
    
public static booleanisDispatchThread()
Returns true if the calling thread is the current AWT EventQueue's dispatch thread.

return
true, if the calling thread is the current AWT EventQueue's dispatch thread; false otherwise.

        return Thread.currentThread() instanceof EventDispatchThread;
    
booleanisEmpty()
Checks if the queue is empty.

return
true, if is empty.

        return getCore().isEmpty();
    
public java.awt.AWTEventpeekEvent()
Returns the first event of the EventQueue (without removing it from the queue).

return
the the first AWT event of the EventQueue.

        return getCore().peekEvent();
    
public java.awt.AWTEventpeekEvent(int id)
Returns the first event of the EventQueue with the specified ID (without removing it from the queue).

param
id the type ID of event.
return
the first event of the EventQueue with the specified ID.

        return getCore().peekEvent(id);
    
protected voidpop()
Stops dispatching events using this EventQueue. Any pending events are transferred to the previous EventQueue.

throws
EmptyStackException is thrown if no previous push was made on this EventQueue.

        getCore().pop();
    
public voidpostEvent(java.awt.AWTEvent event)
Posts a event to the EventQueue.

param
event AWTEvent.

        event.isPosted = true;
        getCore().postEvent(event);
    
public voidpush(java.awt.EventQueue newEventQueue)
Replaces the existing EventQueue with the specified EventQueue. Any pending events are transferred to the new EventQueue.

param
newEventQueue the new event queue.

        getCore().push(newEventQueue);
    
voidsetCore(EventQueueCore newCore)
Sets the core.

param
newCore the new core.

        coreRef.set((newCore != null) ? newCore : new EventQueueCore(this));