Java Platform 1.2
Beta 4

Class java.awt.EventQueue

java.lang.Object
  |
  +--java.awt.EventQueue

public class EventQueue
extends Object
EventQueue is a platform-independent class that queues events, both from the underlying peer classes and from trusted application classes. There is only one EventQueue for the system.


Constructor Summary
EventQueue()
           
 
Method Summary
 void addEventQueueListener(EventQueueListener l)
          Adds an EventListener to receive AWTEvents from this EventQueue.
protected  void dispatchEvent(AWTEvent event)
          Dispatch an event to its source.
 AWTEvent getNextEvent()
          Remove an event from the queue and return it.
static void invokeAndWait(Runnable runnable)
          Causes runnable to have its run() method called in the dispatch thread of the EventQueue.
static void invokeLater(Runnable runnable)
          Causes runnable to have its run() method called in the dispatch thread of the EventQueue.
static boolean isDispatchThread()
          Returns true if the calling thread is this EventQueue's dispatch thread.
protected  void notifyEventQueueListeners(AWTEvent theEvent)
          This method notifies any EventQueueListeners that an event has been posted to the EventQueue.
 AWTEvent peekEvent()
          Return the first event without removing it.
 AWTEvent peekEvent(int id)
           
protected  void pop()
          Stop dispatching events using this EventQueue instance.
 void postEvent(AWTEvent theEvent)
          Post a 1.1-style event to the EventQueue.
 void push(EventQueue newEventQueue)
          Replace the existing EventQueue with the specified one.
 void removeEventQueueListener(EventQueueListener l)
          Removes an EventListener so that it no longer receives events from this EventQueue.
 
Methods inherited from class java.lang.Object
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait
 

Constructor Detail

EventQueue

public EventQueue()
Method Detail

postEvent

public void postEvent(AWTEvent theEvent)
Post a 1.1-style event to the EventQueue. If there is an existing event on the queue with the same ID and event source, the source component's coalesceEvents method will be called. If there are any EventQueueListeners, notifyEventQueueListeners will be called if an event was added to the queue.
Parameters:
theEvent - an instance of java.awt.AWTEvent, or a subclass of it.

getNextEvent

public AWTEvent getNextEvent()
                      throws InterruptedException
Remove an event from the queue and return it. This method will block until an event has been posted by another thread.
Returns:
the next AWTEvent
Throws:
InterruptedException - if another thread has interrupted this thread.

peekEvent

public AWTEvent peekEvent()
Return the first event without removing it.
Returns:
the first event, which is either an instance of java.awt.Event or java.awt.AWTEvent.

peekEvent

public AWTEvent peekEvent(int id)

dispatchEvent

protected void dispatchEvent(AWTEvent event)
Dispatch an event to its source.
Parameters:
theEvent - an instance of java.awt.AWTEvent, or a subclass of it.

push

public void push(EventQueue newEventQueue)
Replace the existing EventQueue with the specified one. Any pending events are transferred to the new EventQueue for processing by it.
Parameters:
an - EventQueue (or subclass thereof) instance to be used.

pop

protected void pop()
            throws EmptyStackException
Stop dispatching events using this EventQueue instance. Any pending events are transferred to the previous EventQueue for processing by it.
Throws:
if - no previous push was made on this EventQueue.

isDispatchThread

public static boolean isDispatchThread()
Returns true if the calling thread is this EventQueue's dispatch thread. Use this call the ensure that a given task is being executed (or not being) on the current EventDispatchThread.
Returns:
true if running on this EventQueue's dispatch thread.

addEventQueueListener

public void addEventQueueListener(EventQueueListener l)
Adds an EventListener to receive AWTEvents from this EventQueue. Listeners continue receiving events if a new EventQueue is pushed or an existing one is popped.

Note: event listener use is not recommended for normal application use, but are intended solely to support special purpose facilities including support for accessibility, event record/playback, and diagnostic tracing.

Parameters:
l - the event listener.
Since:
JDK1.2
See Also:
java.awt.EventQueueListener, removeEventQueueListener(java.awt.event.EventQueueListener)

removeEventQueueListener

public void removeEventQueueListener(EventQueueListener l)
Removes an EventListener so that it no longer receives events from this EventQueue.

Note: event listener use is not recommended for normal application use, but are intended solely to support special purpose facilities including support for accessibility, event record/playback, and diagnostic tracing.

Parameters:
l - the event listener.
Since:
JDK1.2
See Also:
java.awt.EventQueueListener, addEventQueueListener(java.awt.event.EventQueueListener)

notifyEventQueueListeners

protected void notifyEventQueueListeners(AWTEvent theEvent)
This method notifies any EventQueueListeners that an event has been posted to the EventQueue. If an EventQueue subclass overrides postEvent, it must either call this method or call super.postEvent(event).
Parameters:
theEvent - the event which has been posted to the EventQueue.

invokeLater

public static void invokeLater(Runnable runnable)
Causes runnable to have its run() method called in the dispatch thread of the EventQueue. This will happen after all pending events are processed.
Parameters:
runnable - the Runnable whose run() method should be executed synchronously on the EventQueue
Since:
JDK1.2
See Also:
invokeAndWait(java.lang.Runnable)

invokeAndWait

public static void invokeAndWait(Runnable runnable)
                          throws InterruptedException,
                                 InvocationTargetException
Causes runnable to have its run() method called in the dispatch thread of the EventQueue. This will happen after all pending events are processed. The call blocks until this has happened. This method will throw an Error if called from the event dispatcher thread.
Parameters:
runnable - the Runnable whose run() method should be executed synchronously on the EventQueue
Throws:
InterruptedException - if another thread has interrupted this thread
InvocationTargetException - if an exception is thrown when running runnable
Since:
JDK1.2
See Also:
invokeLater(java.lang.Runnable)

Java Platform 1.2
Beta 4

Submit a bug or feature
Submit comments/suggestions about new javadoc look
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.
This documentation was generated with a post-Beta4 version of Javadoc.