0

I have code like this:

JOptionPane pane1 = new JOptionPane();
JDialog dialog1 = pane1.createDialog(null, "Window1");
dialog1.setModal(false);
dialog1.setVisible(true);

JOptionPane pane2 = new JOptionPane();
JDialog dialog2 = pane2.createDialog(null, "Window2");
dialog2.setModal(false);
dialog2.setVisible(true);

The problem is after closing dialogs, program still running. How can I fix that ?

Hovercraft Full Of Eels
  • 280,125
  • 25
  • 247
  • 360
Tonsor
  • 21
  • 1
  • You haven't defined what "closing dialogs" means. If you want to click on the "X" button then you need to set the close operation as: `dialog1.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);`. Now if you click on the "X" button and you don't have any other active dialogs or frames then the JVM will terminate. However, if you click on the "Ok" button of the option pane the JVM will remain running. You need to add a Componentistener to the dialog and handle the `componentHidden()` event. So your question needs to be clarified. – camickr Sep 15 '21 at 20:44

0 Answers0