0

I'm developing a small desktop application for my college java project.

There's a main window which contains a JTable and when i click a specific record it pops out another JFrame containing full details of specific record.

When I click a record and if I click another record without manually closing the first one it still exists.. (anyway it's obvious).

I want to get the first frame to be disposed when ever I click another.

Simply I want only one frame containing details at a time, with the main window..

  • I tried it couple of time using JPanel objects instead of frames and it was useless.
  • And tried this with singleton pattern and when I use it only one frame pops out at a time still.. Contains the same details for every record I click in the table..

What is a method to get this requirement done?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
ZeroKool
  • 13
  • 3
  • 1
    See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/q/9554636/418556) There should be exactly **1 frame per application instance.** The 'Details' view should appear in a `JDialog`. The app. should keep a reference to the dialog and change the state of it (i.e. change the details) when the user chooses a new record to display. – Andrew Thompson Mar 18 '15 at 11:32
  • *"I tried it couple of time using JPanel objects instead of frames and it was useless."* DYM by using a `CardLayout`? – Andrew Thompson Mar 18 '15 at 11:36

1 Answers1

0

Instead of creating new jFrame everytime user clicks on table record, create one jframe first time & reuse the same jframe everytime, it will be good if you can reuse the components of the jframe. You can use JInternalFrame in place of jframe. Post some code as it will be helpful in providing a better solution.

  • 2
    You can't use a JInternalFrame as a popup. A JInternalFrame is designed to be displayed in a JDesktopPane. Use a modal JDialog as the popup window. – camickr Mar 18 '15 at 14:48