Home » openjdk-7 » java » awt » [javadoc | source]
public class: EventQueue [javadoc | source]
EventQueue is a platform-independent class that queues events, both from the underlying peer classes and from trusted application classes.

It encapsulates asynchronous event dispatch machinery which extracts events from the queue and dispatches them by calling dispatchEvent(AWTEvent) method on this EventQueue with the event to be dispatched as an argument. The particular behavior of this machinery is implementation-dependent. The only requirements are that events which were actually enqueued to this queue (note that events being posted to the EventQueue can be coalesced) are dispatched:

That is, it is not permitted that several events from this queue are dispatched simultaneously.
In the same order as they are enqueued.
That is, if AWTEvent A is enqueued to the EventQueue before AWTEvent B then event B will not be dispatched before event A.

Some browsers partition applets in different code bases into separate contexts, and establish walls between these contexts. In such a scenario, there will be one EventQueue per context. Other browsers place all applets into the same context, implying that there will be only a single, global EventQueue for all applets. This behavior is implementation-dependent. Consult your browser's documentation for more information.

For information on the threading issues of the event dispatch machinery, see AWT Threading Issues.

 public EventQueue() 
Method from java.awt.EventQueue Summary:
createSecondaryLoop,   createSecondaryLoop,   detachDispatchThread,   dispatchEvent,   getCurrentEvent,   getDispatchThread,   getMostRecentEventTime,   getMostRecentEventTimeEx,   getNextEvent,   getNextEvent,   getNextEventPrivate,   initDispatchThread,   invokeAndWait,   invokeLater,   isDispatchThread,   isDispatchThreadImpl,   peekEvent,   peekEvent,   pop,   postEvent,   push,   removeSourceEvents,   setCurrentEventAndMostRecentTime
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.awt.EventQueue Detail:
 public SecondaryLoop createSecondaryLoop() 
    Creates a new {@code secondary loop} associated with this event queue. Use the SecondaryLoop#enter and SecondaryLoop#exit methods to start and stop the event loop and dispatch the events from this queue.
 SecondaryLoop createSecondaryLoop(Conditional cond,
    EventFilter filter,
    long interval) 
 final boolean detachDispatchThread(EventDispatchThread edt) 
 protected  void dispatchEvent(AWTEvent event) 
    Dispatches an event. The manner in which the event is dispatched depends upon the type of the event and the type of the event's source object:

    Event Type Source Type Dispatched To
    ActiveEvent Any event.dispatch()
    Other Component source.dispatchEvent(AWTEvent)
    Other MenuComponent source.dispatchEvent(AWTEvent)
    Other Other No action (ignored)

 public static AWTEvent getCurrentEvent() 
    Returns the the event currently being dispatched by the EventQueue associated with the calling thread. This is useful if a method needs access to the event, but was not designed to receive a reference to it as an argument. Note that this method should only be invoked from an application's event dispatching thread. If this method is invoked from another thread, null will be returned.
 final EventDispatchThread getDispatchThread() 
 public static long getMostRecentEventTime() 
    Returns the timestamp of the most recent event that had a timestamp, and that was dispatched from the EventQueue associated with the calling thread. If an event with a timestamp is currently being dispatched, its timestamp will be returned. If no events have yet been dispatched, the EventQueue's initialization time will be returned instead.In the current version of the JDK, only InputEvents, ActionEvents, and InvocationEvents have timestamps; however, future versions of the JDK may add timestamps to additional event types. Note that this method should only be invoked from an application's event dispatching thread . If this method is invoked from another thread, the current system time (as reported by System.currentTimeMillis()) will be returned instead.
 long getMostRecentEventTimeEx() 
 public AWTEvent getNextEvent() throws InterruptedException 
    Removes an event from the EventQueue and returns it. This method will block until an event has been posted by another thread.
 AWTEvent getNextEvent(int id) throws InterruptedException 
 AWTEvent getNextEventPrivate() throws InterruptedException 
 final  void initDispatchThread() 
 public static  void invokeAndWait(Runnable runnable) throws InterruptedException, InvocationTargetException 
 public static  void invokeLater(Runnable runnable) 
 public static boolean isDispatchThread() 
 final boolean isDispatchThreadImpl() 
 public AWTEvent peekEvent() 
    Returns the first event on the EventQueue without removing it.
 public AWTEvent peekEvent(int id) 
    Returns the first event with the specified id, if any.
 protected  void pop() throws EmptyStackException 
    Stops dispatching events using this EventQueue. Any pending events are transferred to the previous EventQueue for processing.

    Warning: To avoid deadlock, do not declare this method synchronized in a subclass.

 public  void postEvent(AWTEvent theEvent) 
    Posts 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.
 public  void push(EventQueue newEventQueue) 
    Replaces the existing EventQueue with the specified one. Any pending events are transferred to the new EventQueue for processing by it.
 final  void removeSourceEvents(Object source,
    boolean removeAllEvents) 
 static  void setCurrentEventAndMostRecentTime(AWTEvent e)