2

I have created a second Frame in another frame. I noticed that when I close the second frame, the first one closes too.

How can i avoid that? I would like the first frame to remain as it is and without closing.

My code for the second frame is:

 JFrame.setDefaultLookAndFeelDecorated(true);       
 frame = new JFrame();
 frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE); //when it closes the first frame closes too

thanks

programmer
  • 4,571
  • 13
  • 49
  • 59
  • Possible duplicate of [Close one JFrame without closing another?](http://stackoverflow.com/questions/1944446/close-one-jframe-without-closing-another) – Blasanka May 13 '17 at 14:47

1 Answers1

5

Solved

I read the following answer Close one JFrame without closing another? and i found the answer

  • I removed

     frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
    
  • and I added the following

     setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    
Community
  • 1
  • 1
programmer
  • 4,571
  • 13
  • 49
  • 59
  • 4
    An aaplication should only has a single JFrame. For child windows you should use a JDialog. See: http://stackoverflow.com/questions/9554636/the-use-of-multiple-jframes-good-bad-practice – camickr Jan 06 '14 at 15:57