Reputation: 25
I have a class which creates a JFrame. When I click on a button in the JFrame, another JFrame in a different class opens up.
Now, when I close the second JFrame, even the first one closes up. Any ideas on preventing this? I want the first frame to remain visible.
Upvotes: 0
Views: 62
Reputation: 1031
Use
JFrame.dispose()
on the second JFrame.
Also when using setDefaultCloseOperation() //this is what happens when you press x on window.
avoid EXIT_ON_CLOSE and use DISPOSE_ON_CLOSE.
PS:Where is the code? :P
Upvotes: 1