This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Hi, I encounter the problem in the code that is pasted below and have no idea where the problem lies. The crucial part of the code is MyAction.actionPerformed method. It simply makes the modal-dialog visible (which blocks the thread) but on the previous line it starts the thread that will call the SwingUtilities.invokeLater with the Runnable that hides the dialog. This way the thread that shows the dialog will be blocked till the thread that calls invokeLater does his jobs and hides the dialog. All code runs in Swing-event-thread except the Thread that is created only invoke the SwingUtilities.invokeLater method. The problem is that when you run the app and try to run the MyAction (it is plugged as GO item in the frame's menu) a few times you see that the dialog is not alway correctly hidden (someties I need 20 tries to see the effect). Sometimes the bug manifest itself by not hiding the dialog (and additionaly the dialog is broken - either it does not have anything inside contentPane or it is just window-title-bar without any content below) sometimes the dialog is hidden but the frame does not give the focus back (as if the dialog was still displayed but was invisible). Calling the dispose instead of setVisible(false) has the similar effect. The problem looks like some kind of race, but how it could be if everything is done from the Swing-thread. I observer the problem on sun-jdk-184.108.40.206 and ibm-jdk-220.127.116.11 I would be grateful for any tips on that problem.