3

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.

Roham Rafii
  • 2,929
  • 7
  • 35
  • 49
Mukthi
  • 561
  • 4
  • 13
  • 35

3 Answers3

8

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);
Swaranga Sarma
  • 13,055
  • 19
  • 60
  • 93
  • Thanks for your reply.Its working,so i got a solution for my first question.Can you please help me for the second. – Mukthi Sep 02 '11 at 06:33
  • 2
    @sakthibalaji...Please post an SSCCE. From what I can guess, you need to add an `ActionListener` to the button and do the updating part in the `actionPerformed` method. – Swaranga Sarma Sep 02 '11 at 06:38
  • 2
    Technically, the OP was using the *right* method with the *wrong* argument. ;) – Andrew Thompson Sep 02 '11 at 07:09
3

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

mKorbel
  • 109,525
  • 20
  • 134
  • 319
3

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.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045