Hi all,

I've got a JFrame in a program, and when I click on a button, I get another JFrame created, and then select from a list.

This works fine. But my problem is that when I close the second JFrame the entire program exits (both the main JFrame and the second JFrame).

I've tried the following commands:

JFrame.EXIT_ON_CLOSE
JFrame.DO_NOTHING_ON_CLOSE
JFrame.DISPOSE_ON_CLOSE

But no luck with the above. At least I'm not getting them to work. They all close the entire program.

Any help much appreciated.

Thanks,
Jorge

Haven't really dealt with this before, but have you tried:

JFrame.HIDE_ON_CLOSE

Not sure if the results will be different. Might have the main JFrame dispose of them both on exit

Haven't really dealt with this before, but have you tried:

JFrame.HIDE_ON_CLOSE

Not sure if the results will be different. Might have the main JFrame dispose of them both on exit

tried that... no luck. not working for me.

Well, your second JFrame probably has a call to setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE) somewhere in its setup code. You need to change that to use DISPOSE_ON_CLOSE or something else. Those are not commands. They are constants you use to specify the parameter value.

Hi all,

Thanks! I got the *constant* change to work.

Not sure what was happening before... somehow it was carrying the constant value from the first JFrame (???).

Thanks again from a Java newbie

This question has already been answered. Start a new discussion instead.