문제

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

도움이 되었습니까?

해결책

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);
    
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top