If an event handler throws an exception which it does not itself catch, there is a crash in the current EventQueue DispatchThread.
Created May 4, 2012
Peter Gadjokov Quoted below is the is the documentation of the private method handleException of java.awt.EventDispatchThread. It's not a long-term solution but it does work.
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.
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:
- Load the class named by the value of that property, using the current thread's context class loader,
- Instantiate that class using its zero-argument constructor,
- Find the resulting handler object's public void handle
method, which should take a single argument of type
Throwable, and
- Invoke the handler's handle method, passing it the thrown argument that was passed to this method.