I have a Swing application, and even though I have everything in a try
/block
, the exception isn\'t caught.
public static void main(
As mentioned by another poster, your problem is that the exception is being thrown in another thread, the event dispatch thread. A couple of solutions:
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread t, Throwable e) {
// ... do something with exception here ...
}
});
On a side-note, you should in principle but your UI startup code in a SwingUtilities.invokeLater().