abbot.util
Class EventDispatchExceptionHandler

java.lang.Object
  extended by abbot.util.EventDispatchExceptionHandler
Direct Known Subclasses:
EDTExceptionCatcher, EventExceptionHandler

public class EventDispatchExceptionHandler
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
EventDispatchExceptionHandler()
           
 
Method Summary
protected  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

PROP_NAME

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

See Also:
Constant Field Values
Constructor Detail

EventDispatchExceptionHandler

public EventDispatchExceptionHandler()
Method Detail

install

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.

Throws:
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. // TODO: read the private static field // String EventDispatchThread.handlerClassName and override it if // necessary.

exceptionCaught

protected void exceptionCaught(Throwable thrown)
Define this to handle the exception as needed. Default prints a warning to System.err.


handle

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


isInstalled

public static boolean isInstalled()


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

SourceForge