Invoking JDialog on every exception
Hello,
In my application I want to a feature that would show up a dialog when an exception (checked or unchecked) is thrown.
The simpliest solution - putting all of main() in try/catch block, and adding dialog code in every catch, is not very good I guess - code inside try/catch executes considerably slower (I read it in Effective Java by Joshua Bloch), so what is the right way to invoke dialogs on exeptions?
Man, if you have an exception and are about to show a dialog (eventually asking the user what to do), performance is not really the issue. We're not talking about slower like "it takes 10 seconds per line". It's a slowdown you'll never notice.
And use JOptionPane, might be easier and more standard.
That's true. The performance overhead is non-existant. I remember reading somewhere that in the case that no exception is thrown it is indeed zero (null, nada, zip, ...) but I can't be bothered to find that place right now. And even if it isn't really zero it's near enough to be seen like that for every practical purpose.