tags:

views:

1121

answers:

4

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.

+1  A: 

Is there a reason why you're not using a JDialog instead of a JFrame?

discgolfer
+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
A: 

Use this:

jFrame.setUndecorated(true);
jFrame.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
NovemberRain
A: 

may i know where is your code?

princess..