Name: gm110360 Date: 05/17/2004
FULL PRODUCT VERSION :
java version "1.4.2_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02)
Java HotSpot(TM) Client VM (build 1.4.2_03-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Calling dispose() on a modal dialog, and then making it visible again can cause the Dialogs modality to be lost (it doesn't happen all the time, so I would assume it is a race condition between 2 Threads)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
compile and execute the code supplied.
Close the dialog rapidly, and watch the integer counter increase on std out.
After several closes, show() will stop blocking, and the counter will rapidly increase.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
show() should block until the dialog is closed.
ACTUAL -
show() blocks for the 1st few closes of the Dialog, but eventually the Dialog will lose its modality, and show() will stop blocking.
REPRODUCIBILITY :
This bug can be reproduced often.
---------- BEGIN SOURCE ----------
import javax.swing.*;
public class DialogBug
{
public static void main(String [] args)
{
JDialog fred = new JDialog((JFrame)null, true);
fred.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
int i = 0;
while(true)
{
System.out.println(i++);
fred.show();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
a) do not dispose of components.. or
b) Only make AWT & Swing components visible through the event dispatch Thread.
EventQueue.invokeAndWait(new Runnable() { public void run(){ component.setVisible(true)}});
Neither of these solutions is realy practical however.
(Incident Review ID: 260455)
======================================================================