How can I avoid, that a dialog is shown, when there already is one on the screen?
Details: In my application many Timers are running. If a fatal error occurs, all the affected threads are going to show a JDialog (by swingx.JXErrorPane.showDialog()), which is not desired. Even if I cancel all the running Timers, still some Dialogs will appear at the same time. How can I achieve that there will only appear one dialog?
I tried to make the method which calls showDialog() synchronized, which results in my whole GUI being blocked. Usage of a flag didn’t work either.
Turn the dialog into an observer and publish the error events to this new observer (see the Observer Design Pattern). When an event happens, the dialog should show itself (with the main frame as the parent). Display the recent errors in a table in the dialog. Add new errors to the bottom of that table.
Another option is to display the errors in a table in the main frame. Put the table into a JSplitPane so users can minimize it.