Class AbstractEventExceptionHandler

Direct Known Subclasses:
ComponentTestFixture.ExceptionCatcher, EventExceptionHandler

public abstract class AbstractEventExceptionHandler
extends Object

Handler for uncaught exceptions on any event dispatch thread. Once this has been installed, the class must be accessible by any subsequently launched dispatch thread.

This handler is installed by setting the System property sun.awt.exception.handler. See javadoc for java.awt.EventDispatchThread for details. This is sort of a patch to Sun's implementation, which only checks the property once and caches the result ever after. This implementation will always chain to the handler indicated by the current value of the property.

It is most definitely NOT safe to try to install several of these on different threads.

Field Summary
static String PROP_NAME
          See javadoc for java.awt.EventDispatchThread.
Constructor Summary
Method Summary
protected abstract  void exceptionCaught(Throwable thrown)
          Define this to handle the exception as needed.
 void handle(Throwable thrown)
          Handle exceptions thrown on the event dispatch thread.
 void install()
          Install a handler for event dispatch exceptions.
static boolean isInstalled()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


public static final String PROP_NAME
See javadoc for java.awt.EventDispatchThread.

See Also:
Constant Field Values
Constructor Detail


public AbstractEventExceptionHandler()
Method Detail


public void install()
Install a handler for event dispatch exceptions. This is kind of a hack, but it's Sun's hack. See the javadoc for java.awt.EventDispatchThread for details. NOTE: we throw an exception immediately, which ensures that our handler is installed, since otherwise someone might set this property later. java.awt.EventDispatchThread doesn't actually load the handler specified by the property until an exception is caught by the event dispatch thread. SwingSet2 in 1.4.1 installs its own. Note that a new instance is created for each exception thrown.

RuntimeException - if the handler cannot be installed.
IllegalStateException - if this method is invoked from an event dispatch thread.
IllegalArgumentException - if the given class is not derived from this one.


protected abstract void exceptionCaught(Throwable thrown)
Define this to handle the exception as needed.


public void handle(Throwable thrown)
Handle exceptions thrown on the event dispatch thread.


public static boolean isInstalled()

Copyright 2002-2004 Timothy Wall. All Rights Reserved.
Abbot is hosted on