Question

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

Was it helpful?

Solution

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);
    
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top