-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
6
-
x86
-
linux
FULL PRODUCT VERSION :
1.5.0_15
1.6.0_07
ADDITIONAL OS VERSION INFORMATION :
Fedora 7
A DESCRIPTION OF THE PROBLEM :
For JDialogs with null parent java will continue call dispose() method even they already were disposed. If you have for example 5 dialogs with null parent (4 already disposed, 1 showing), then after calling disposed on that 1 dialog, java will call dispose on the rest 4 dialogs.
Also all hided dialogs can be finalized, and dispose() won't be called on them, but we can't trust garbage collector.
All works correctly if dialogs have parent dialogs or frames.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) show 2 dialogs (new JDialog(null) ) and show them
2) call dispose() on first.
3) call dispose() on second and you can see that dispose() method was also called on first one.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class TestFrame extends JFrame
{
private int i = 0;
public static void main(String args[])
{
JFrame frame = new TestFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public TestFrame()
{
JButton btnShowDialog = new JButton(new AbstractAction("Show New")
{
public void actionPerformed(ActionEvent e)
{
JDialog dialog = new TestDialog(i);
i++;
dialog.setVisible(true);
}
});
add(btnShowDialog);
}
}
public class TestDialog extends JDialog
{
final int number;
private int count = 0;
public TestDialog(int number)
{
this.number = number;
setTitle("Dialog number: " + String.valueOf(number));
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
setSize(300, 100);
setLocationRelativeTo(null);
}
public void dispose()
{
this.count++;
System.out.println("disposing dialog number: " + number + " [" + count + " times ]");
super.dispose();
}
}
---------- END SOURCE ----------
1.5.0_15
1.6.0_07
ADDITIONAL OS VERSION INFORMATION :
Fedora 7
A DESCRIPTION OF THE PROBLEM :
For JDialogs with null parent java will continue call dispose() method even they already were disposed. If you have for example 5 dialogs with null parent (4 already disposed, 1 showing), then after calling disposed on that 1 dialog, java will call dispose on the rest 4 dialogs.
Also all hided dialogs can be finalized, and dispose() won't be called on them, but we can't trust garbage collector.
All works correctly if dialogs have parent dialogs or frames.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) show 2 dialogs (new JDialog(null) ) and show them
2) call dispose() on first.
3) call dispose() on second and you can see that dispose() method was also called on first one.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class TestFrame extends JFrame
{
private int i = 0;
public static void main(String args[])
{
JFrame frame = new TestFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public TestFrame()
{
JButton btnShowDialog = new JButton(new AbstractAction("Show New")
{
public void actionPerformed(ActionEvent e)
{
JDialog dialog = new TestDialog(i);
i++;
dialog.setVisible(true);
}
});
add(btnShowDialog);
}
}
public class TestDialog extends JDialog
{
final int number;
private int count = 0;
public TestDialog(int number)
{
this.number = number;
setTitle("Dialog number: " + String.valueOf(number));
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
setSize(300, 100);
setLocationRelativeTo(null);
}
public void dispose()
{
this.count++;
System.out.println("disposing dialog number: " + number + " [" + count + " times ]");
super.dispose();
}
}
---------- END SOURCE ----------