Name: gm110360 Date: 09/11/2002
FULL PRODUCT VERSION :
java version "1.4.1-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-rc-b19)
Java HotSpot(TM) Client VM (build 1.4.1-rc-b19, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 5.00.2195 Service Pack 2
ADDITIONAL OPERATING SYSTEMS :
Linux Slackware 8.0, kernel 2.4.14
A DESCRIPTION OF THE PROBLEM :
Once an ownerless JDialog is called, the JVM hangs after
disposing the main JFrame.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the attached source code: javac Hang.java
2. Run the test case: java Hang
3. If you select the close button the app will close
normally, but if you select the show dialog button, closes
it and then close the app, the JVM will hang
EXPECTED VERSUS ACTUAL BEHAVIOR :
The app should exit smoothly even if a ownerless JDialog
was called
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Hang extends JFrame {
JPanel jPanel1 = new JPanel();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
public static void main(String[] args) {
Hang f = new Hang();
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setSize(400,400);
f.show();
}
public Hang() {
jPanel1.setLayout(null);
jButton1.setBounds(new Rectangle(52, 70, 137, 36));
jButton1.setText("Show Dialog");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
D1 d = new D1();
d.show();
}
});
jButton2.setBounds(new Rectangle(206, 68, 137, 39));
jButton2.setText("Close");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
hide();
dispose();
}
});
this.getContentPane().add(jPanel1, BorderLayout.CENTER);
jPanel1.add(jButton1, null);
jPanel1.add(jButton2, null);
}
class D1 extends JDialog {
JPanel jPanel1 = new JPanel();
JButton jButton1 = new JButton();
public D1() {
setSize(300,300);
jPanel1.setLayout(null);
jButton1.setBounds(new Rectangle(92, 110, 104, 36));
jButton1.setText("Close");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
hide();
dispose();
}
});
this.getContentPane().add(jPanel1, BorderLayout.CENTER);
jPanel1.add(jButton1, null);
}
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
- Set explicitly an owner to the JDialog, or
- Dispose explicitly the hidden shared owner created by the
JDK that's stored in the AppContext ( getOwner().dispose
() ), or
- Call System.exit
(Review ID: 164286)
======================================================================