If an event handler throws an exception which it does not itself catch, there is a crash in the current EventQueue DispatchThread.

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.

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.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact