java.awt
Class EventDispatchThread

java.lang.Object
  extended byjava.lang.Thread
      extended byjava.awt.EventDispatchThread
All Implemented Interfaces:
Runnable

class EventDispatchThread
extends Thread

EventDispatchThread is a package-private AWT class which takes events off the EventQueue and dispatches them to the appropriate AWT components. The Thread starts a "permanent" event pump with a call to pumpEvents(Conditional) in its run() method. Event handlers can choose to block this event pump at any time, but should start a new pump (not a new EventDispatchThread) by again calling pumpEvents(Conditional). This secondary event pump will exit automatically as soon as the Condtional evaluate()s to false and an additional Event is pumped and dispatched.

Since:
1.1
Author:
Tom Ball, Amy Fowler, Fred Ecks, David Mendenhall

Nested Class Summary
(package private)  class EventDispatchThread.EmptyEvent
           
 
Field Summary
private static int ANY_EVENT
           
private static sun.awt.DebugHelper dbg
           
private  boolean doDispatch
           
private static String handlerClassName
           
private static String handlerPropName
           
private static String NO_HANDLER
           
private  EventQueue theQueue
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
(package private) EventDispatchThread(ThreadGroup group, String name, EventQueue queue)
           
 
Method Summary
(package private)  EventQueue getEventQueue()
           
private  boolean handleException(Throwable thrown)
          Handles an exception thrown in the event-dispatch thread.
(package private)  boolean isDispatching(EventQueue eq)
           
private  void processException(Throwable e, boolean isModal)
           
(package private)  void pumpEvents(Conditional cond)
           
(package private)  void pumpEvents(int id, Conditional cond)
           
(package private)  void pumpEventsForHierarchy(Conditional cond, Component modalComponent)
           
(package private)  void pumpEventsForHierarchy(int id, Conditional cond, Component modalComponent)
           
(package private)  boolean pumpOneEventForHierarchy(int id, Component modalComponent)
           
 void run()
          If this thread was constructed using a separate Runnable run object, then that Runnable object's run method is called; otherwise, this method does nothing and returns.
 void stopDispatching()
           
(package private)  void stopDispatchingImpl(boolean wait)
           
 void stopDispatchingLater()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dbg

private static final sun.awt.DebugHelper dbg

theQueue

private EventQueue theQueue

doDispatch

private boolean doDispatch

ANY_EVENT

private static final int ANY_EVENT
See Also:
Constant Field Values

handlerPropName

private static final String handlerPropName
See Also:
Constant Field Values

handlerClassName

private static String handlerClassName

NO_HANDLER

private static String NO_HANDLER
Constructor Detail

EventDispatchThread

EventDispatchThread(ThreadGroup group,
                    String name,
                    EventQueue queue)
Method Detail

stopDispatchingImpl

void stopDispatchingImpl(boolean wait)

stopDispatching

public void stopDispatching()

stopDispatchingLater

public void stopDispatchingLater()

run

public void run()
Description copied from class: Thread
If this thread was constructed using a separate Runnable run object, then that Runnable object's run method is called; otherwise, this method does nothing and returns.

Subclasses of Thread should override this method.

Specified by:
run in interface Runnable
Overrides:
run in class Thread
See Also:
Thread.start(), Thread.stop(), Thread.Thread(java.lang.ThreadGroup, java.lang.Runnable, java.lang.String), Runnable.run()

pumpEvents

void pumpEvents(Conditional cond)

pumpEventsForHierarchy

void pumpEventsForHierarchy(Conditional cond,
                            Component modalComponent)

pumpEvents

void pumpEvents(int id,
                Conditional cond)

pumpEventsForHierarchy

void pumpEventsForHierarchy(int id,
                            Conditional cond,
                            Component modalComponent)

pumpOneEventForHierarchy

boolean pumpOneEventForHierarchy(int id,
                                 Component modalComponent)

processException

private void processException(Throwable e,
                              boolean isModal)

handleException

private boolean handleException(Throwable thrown)
Handles an exception thrown in the event-dispatch thread.

If the system property "sun.awt.exception.handler" is defined, then when this method is invoked it will attempt to do the following:

  1. Load the class named by the value of that property, using the current thread's context class loader,
  2. Instantiate that class using its zero-argument constructor,
  3. Find the resulting handler object's public void handle method, which should take a single argument of type Throwable, and
  4. Invoke the handler's handle method, passing it the thrown argument that was passed to this method.
If any of the first three steps fail then this method will return false and all following invocations of this method will return false immediately. An exception thrown by the handler object's handle will be caught, and will cause this method to return false. If the handler's handle method is successfully invoked, then this method will return true. This method will never throw any sort of exception.

Note: This method is a temporary hack to work around the absence of a real API that provides the ability to replace the event-dispatch thread. The magic "sun.awt.exception.handler" property will be removed in a future release.

Parameters:
thrown - The Throwable that was thrown in the event-dispatch thread
Returns:
false if any of the above steps failed, otherwise true

isDispatching

boolean isDispatching(EventQueue eq)

getEventQueue

EventQueue getEventQueue()