I am developing a Swing application with a component performing custom painting. When I make some mistake in the painting code and an exception is thrown, the situation is h
In Java
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) {
logger.error("Uncaught exception in thread: " + t.getName, e);
}
});
In any case you should in principle but your UI startup code in a
EventQueue.invokeLater();
or SwingUtilities.invokeLater() that directly call this.
In Scala
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() {
def uncaughtException(t: Thread, e: Throwable) {
logger.error("Uncaught exception in thread: " + t.getName, e)
}
})
In any case you should in principle but your UI startup code in a
EventQueue.invokeLater()