0

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

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by jorgelex008
0

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

0

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.

0

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.

0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.