Reputation: 4901
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
Upvotes: 2
Views: 7822
Reputation: 4901
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);
Upvotes: 5