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?

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.

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!

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.