I have a weird behavior with the JOptionPane.showInputDialog(...) method (and other methods of JJOptionPane). The dialogs created never seem to die. When I call Window.getWindows() after the dialog has disappeared, the number of windows has increased!
Test this program and you see what I mean:
public static void main(String[] args) {
final JFrame frame = new JFrame();
final JPanel panel = new JPanel();
final JButton button = new JButton("Show Dialog");
panel.add(button);
frame.add(panel);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
JOptionPane.showInputDialog(frame, "Enter some text : ");
System.out.println(Window.getWindows().length);
}
});
frame.setSize(400, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
Can someone explain what is happening?