i have a frame that instantiates another frame but i don't want to use the close(x) button on the instantiated frame., so i created a button. how do i code that this button can be used to close the instantiated frame without quitting the JVM.
views:
1121answers:
4
+1
A:
Is there a reason why you're not using a JDialog instead of a JFrame?
discgolfer
2008-12-09 18:32:56
+1
A:
Having your own close button is weird UI and should be avoided.
To get rid of a frame when your own button is clicked you can just jFrame.setVisible(false) or jFrame.dispose if you want to get rid of it completely.
On frames you don't want to exit the JVM on the close button being clicked specify:
jFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
or
jFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
Depending on which of the behaviour you want.
Tom
2009-01-10 08:55:57
A:
Use this:
jFrame.setUndecorated(true);
jFrame.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
NovemberRain
2009-11-16 15:46:03