0

I have created two classes. One is my main GUI the other is my popup GUI which is launced via a button click.

How ever when i click the close button on my popup GUI it closes all the JFrames.

Here is my main GUI

public FirstAid() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 700, 507);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(new BorderLayout(0, 0));

My popup GUI also has the

EXIT_ON_CLOSE
friedrojak
  • 57
  • 1
  • 13

1 Answers1

1

What you want, as mentioned in the comments is DISPOSE_ON_CLOSE. And here's why:

EXIT_ON_CLOSE will terminate the program.

DISPOSE_ON_CLOSE will call dispose() on the frame, which will make the [single] frame disappear and remove the resources that it's using.

Source

Community
  • 1
  • 1
benscabbia
  • 17,592
  • 13
  • 51
  • 62