java.awt
Class EventQueue
This class manages a queue of AWTEvent
objects that
are posted to it. The AWT system uses only one event queue for all
events.
EventQueue() - Initializes a new instance of
EventQueue .
|
protected void | dispatchEvent(AWTEvent evt) - Dispatches an event.
|
static AWTEvent | getCurrentEvent() - Return the event currently being dispatched by the event
dispatch thread.
|
static long | getMostRecentEventTime() - Returns the timestamp of the most recent event that had a timestamp, or
the initialization time of the event queue if no events have been fired.
|
AWTEvent | getNextEvent() - Returns the next event in the queue.
|
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) - This arranges for runnable to have its run method called in the
dispatch thread of the EventQueue.
|
static boolean | isDispatchThread() - Return true if the current thread is the current AWT event dispatch
thread.
|
AWTEvent | peekEvent() - Returns the next event in the queue without removing it from the queue.
|
AWTEvent | peekEvent(int id) - Returns the next event in the queue that has the specified id
without removing it from the queue.
|
protected void | pop() - Transfer any pending events from this queue back to the parent queue that
was previously push()ed.
|
void | postEvent(AWTEvent evt) - Posts a new event to the queue.
|
void | push(EventQueue newEventQueue) - Allows a custom EventQueue implementation to replace this one.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
EventQueue
public EventQueue()
Initializes a new instance of EventQueue
.
dispatchEvent
protected void dispatchEvent(AWTEvent evt)
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.
getCurrentEvent
public static AWTEvent getCurrentEvent()
Return the event currently being dispatched by the event
dispatch thread. If the current thread is not the event
dispatch thread, this method returns null.
getMostRecentEventTime
public static long getMostRecentEventTime()
Returns the timestamp of the most recent event that had a timestamp, or
the initialization time of the event queue if no events have been fired.
At present, only InputEvent
s, ActionEvent
s,
InputMethodEvent
s, and InvocationEvent
s have
timestamps, but this may be added to other events in future versions.
If this is called by the event dispatching thread, it can be any
(sequential) value, but to other threads, the safest bet is to return
System.currentTimeMillis().
- the most recent timestamp
getNextEvent
public AWTEvent getNextEvent()
throws InterruptedException
Returns the next event in the queue. This method will block until
an event is available or until the thread is interrupted.
- The next event in the queue.
InterruptedException
- If this thread is interrupted while
waiting for an event to be posted to the queue.
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.
invokeLater
public static void invokeLater(Runnable runnable)
This arranges for runnable to have its run method called in the
dispatch thread of the EventQueue. This will happen after all
pending events are processed.
isDispatchThread
public static boolean isDispatchThread()
Return true if the current thread is the current AWT event dispatch
thread.
peekEvent
public AWTEvent peekEvent()
Returns the next event in the queue without removing it from the queue.
This method will block until an event is available or until the thread
is interrupted.
- The next event in the queue.
peekEvent
public AWTEvent peekEvent(int id)
Returns the next event in the queue that has the specified id
without removing it from the queue.
This method will block until an event is available or until the thread
is interrupted.
id
- The event id to return.
- The next event in the queue.
pop
protected void pop()
throws EmptyStackException
Transfer any pending events from this queue back to the parent queue that
was previously push()ed. Event dispatch from this queue is suspended.
postEvent
public void postEvent(AWTEvent evt)
Posts a new event to the queue.
evt
- The event to post to the queue.
push
public void push(EventQueue newEventQueue)
Allows a custom EventQueue implementation to replace this one.
All pending events are transferred to the new queue. Calls to postEvent,
getNextEvent, and peekEvent and others are forwarded to the pushed queue
until it is removed with a pop().
EventQueue.java --
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath 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 2, or (at your option)
any later version.
GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.