0

I have a JFrame that I call from another JFrame like so:

Viewer2D v = new Viewer2D(this);
v.setVisible(true);
v.DrawAssembly(glNameList.get(hitRecs.get(0).getNames()[0]));

I set the exit action to an action listener and call dispose() and both of my JFrames disappear! How do I get only the one I'm working on to close?

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by BestJewSinceJC
0

If you dispose a parent component you also automatically are disposing of all the child components. Presumably you're calling dispose() on the outer JFrame, which is causing the inner one to disappear? If you want to remove the JFrame, you can just call firstJframe.remove(otherJFrame); and it will be removed automatically. You might have to call validate() on the firstJframe in order to get it to redraw itself properly.

0

No, the dispose is in the second JFrame. That is what has me confused!

FrameA calls FrameB
someone closes FrameB and the event calls dispose on FrameB
FrameA and FrameB disappear!

0

Can you please post a minimal example of what you are doing? Calling dispose() as you know should only dispose of the component you call it on and that component's child components and sub-components, AFAIK.

This topic has been dead for over six months. 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.