Java Doc for EventQueue.java in  » 6.0-JDK-Core » AWT » java » awt » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » AWT » java.awt 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.awt.EventQueue

EventQueue
public class EventQueue (Code)
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 EventQueue.dispatchEvent(AWTEvent) 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:

Sequentially.
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.
author:
   Thomas Ball
author:
   Fred Ecks
author:
   David Mendenhall
version:
   1.114, 06/05/07
since:
   1.1




Constructor Summary
public  EventQueue()
    

Method Summary
final  voiddetachDispatchThread()
    
protected  voiddispatchEvent(AWTEvent event)
     Dispatches an event.
public static  AWTEventgetCurrentEvent()
     Returns the the event currently being dispatched by the EventQueue associated with the calling thread.
final  EventDispatchThreadgetDispatchThread()
    
public static  longgetMostRecentEventTime()
     Returns the timestamp of the most recent event that had a timestamp, and that was dispatched from the EventQueue associated with the calling thread.
synchronized  longgetMostRecentEventTimeEx()
    
public  AWTEventgetNextEvent()
     Removes an event from the EventQueue and returns it.
 AWTEventgetNextEvent(int id)
    
final  voidinitDispatchThread()
    
public static  voidinvokeAndWait(Runnable runnable)
     Causes runnable to have its run method called in the dispatch thread of Toolkit.getSystemEventQueue the system EventQueue . This will happen after all pending events are processed. The call blocks until this has happened.
public static  voidinvokeLater(Runnable runnable)
     Causes runnable to have its run method called in the dispatch thread of Toolkit.getSystemEventQueue the system EventQueue .
public static  booleanisDispatchThread()
     Returns true if the calling thread is the current AWT EventQueue's dispatch thread.
public synchronized  AWTEventpeekEvent()
     Returns the first event on the EventQueue without removing it.
public synchronized  AWTEventpeekEvent(int id)
     Returns the first event with the specified id, if any.
protected  voidpop()
     Stops dispatching events using this EventQueue. Any pending events are transferred to the previous EventQueue for processing.
public  voidpostEvent(AWTEvent theEvent)
     Posts a 1.1-style event to the EventQueue.
final  voidpostEventPrivate(AWTEvent theEvent)
     Posts a 1.1-style event to the EventQueue.
public synchronized  voidpush(EventQueue newEventQueue)
     Replaces the existing EventQueue with the specified one.
final  voidremoveSourceEvents(Object source, boolean removeAllEvents)
    
static  voidsetCurrentEventAndMostRecentTime(AWTEvent e)
    


Constructor Detail
EventQueue
public EventQueue()(Code)




Method Detail
detachDispatchThread
final void detachDispatchThread()(Code)



dispatchEvent
protected void dispatchEvent(AWTEvent event)(Code)
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)


Parameters:
  event - an instance of java.awt.AWTEvent,or a subclass of it
throws:
  NullPointerException - if event is null
since:
   1.2



getCurrentEvent
public static AWTEvent getCurrentEvent()(Code)
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. the event currently being dispatched, or null if this method isinvoked on a thread other than an event dispatching thread
since:
   1.4



getDispatchThread
final EventDispatchThread getDispatchThread()(Code)



getMostRecentEventTime
public static long getMostRecentEventTime()(Code)
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. the timestamp of the last InputEvent,ActionEvent, or InvocationEvent to bedispatched, or System.currentTimeMillis() if thismethod is invoked on a thread other than an event dispatchingthread
See Also:   java.awt.event.InputEvent.getWhen
See Also:   java.awt.event.ActionEvent.getWhen
See Also:   java.awt.event.InvocationEvent.getWhen
since:
   1.4



getMostRecentEventTimeEx
synchronized long getMostRecentEventTimeEx()(Code)
most recent event time on all threads.



getNextEvent
public AWTEvent getNextEvent() throws InterruptedException(Code)
Removes an event from the EventQueue and returns it. This method will block until an event has been posted by another thread. the next AWTEvent
exception:
  InterruptedException - if any thread has interrupted this thread



getNextEvent
AWTEvent getNextEvent(int id) throws InterruptedException(Code)



initDispatchThread
final void initDispatchThread()(Code)



invokeAndWait
public static void invokeAndWait(Runnable runnable) throws InterruptedException, InvocationTargetException(Code)
Causes runnable to have its run method called in the dispatch thread of Toolkit.getSystemEventQueue the system 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 runmethod should be executedsynchronously on the EventQueue
exception:
  InterruptedException - if any thread hasinterrupted this thread
exception:
  InvocationTargetException - if an throwable is thrownwhen running runnable
See Also:   EventQueue.invokeLater
since:
   1.2



invokeLater
public static void invokeLater(Runnable runnable)(Code)
Causes runnable to have its run method called in the dispatch thread of Toolkit.getSystemEventQueue the system EventQueue . This will happen after all pending events are processed.
Parameters:
  runnable - the Runnable whose runmethod should be executedsynchronously on the EventQueue
See Also:   EventQueue.invokeAndWait
since:
   1.2



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



peekEvent
public synchronized AWTEvent peekEvent()(Code)
Returns the first event on the EventQueue without removing it. the first event



peekEvent
public synchronized AWTEvent peekEvent(int id)(Code)
Returns the first event with the specified id, if any.
Parameters:
  id - the id of the type of event desired the first event of the specified id or nullif there is no such event



pop
protected void pop() throws EmptyStackException(Code)
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.
exception:
  EmptyStackException - if no previous push was madeon this EventQueue
See Also:   java.awt.EventQueue.push
since:
   1.2




postEvent
public void postEvent(AWTEvent theEvent)(Code)
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.
Parameters:
  theEvent - an instance of java.awt.AWTEvent,or a subclass of it
throws:
  NullPointerException - if theEvent is null



postEventPrivate
final void postEventPrivate(AWTEvent theEvent)(Code)
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.
Parameters:
  theEvent - an instance of java.awt.AWTEvent,or a subclass of it



push
public synchronized void push(EventQueue newEventQueue)(Code)
Replaces the existing EventQueue with the specified one. Any pending events are transferred to the new EventQueue for processing by it.
Parameters:
  newEventQueue - an EventQueue(or subclass thereof) instance to be use
See Also:   java.awt.EventQueue.pop
throws:
  NullPointerException - if newEventQueue is null
since:
   1.2



removeSourceEvents
final void removeSourceEvents(Object source, boolean removeAllEvents)(Code)



setCurrentEventAndMostRecentTime
static void setCurrentEventAndMostRecentTime(AWTEvent e)(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.