Mukthi
Mukthi

Reputation: 571

Closing newly opened JFrame

I'm developing a desktop application using NetBeans IDE.

1) I'm opening a new JFrame after a button click. While I'm closing any of the opened frames, both are getting closed.

2) And I want to update a new Tabbed JPanel on a JFrame after button click. Thanks in advance.

Upvotes: 3

Views: 180

Answers (3)

Swaranga Sarma
Swaranga Sarma

Reputation: 13433

Probably you are using the wrong argument. I guess for the JFrames that you want to close without closing the entire application you are doing:

jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

While to actually close only the desired frame without closing rest of the frames you need to do:

jFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

Upvotes: 8

trashgod
trashgod

Reputation: 205875

I want to update a new JTabbedPane on a JFrame after the button click.

You can just update via a reference to the tab's JPanel and call repaint(), but sooner or later you should consider the Model–View–Controller pattern.

Upvotes: 3

mKorbel
mKorbel

Reputation: 109823

1) Why did you create lots of Top-Level Containers on Runtime, create only one JFrame and other would be JDialog(Modality) or JWindow(un-decorated), re-use that,

2) really no battery included in my Magic Globe today, for better and sooner hepl you have to post here SSCCE

Upvotes: 3

Related Questions