0

I am writing a Swing Menu based application. In the Menu I have File->New->Add Person Here Add Person is a form and the new option will have many other forms. When I click on any of this form it has to be added to the menu display area.

My question is how do I add it to the display area. should the display area already consist of any swing container to which I can add my Forms?

Also, note that each of these Forms that I have created are individual JFrames

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Alwin Doss
  • 962
  • 2
  • 16
  • 33

3 Answers3

3

Also, note that each of these Forms that I have created are individual JFrames

  • never to use lots of JFrames, this is road to the hell

My question is how do I add it to the display area. should the display area already consist of any swing container to which I can add my Forms?

  • if you need popup window then to use JDialog, only one JDialog and re_use that for another action

I am writing a Swing Menu based application. In the Menu I have File->New->Add Person Here Add Person is a form and the new option will have many other forms. When I click on any of this form it has to be added to the menu display area.

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

You can go with the JInternalFrame option. It helps you to do your requirement, refer the links,

http://docs.oracle.com/javase/tutorial/uiswing/components/internalframe.html

Also refer this link for examples,

http://www.java2s.com/Code/Java/Swing-JFC/InterestingthingsusingJInternalFramesJDesktopPaneandDesktopManager2.htm

Vinesh
  • 933
  • 2
  • 7
  • 22
  • An related example connecting internal frames & menus is cited [here](http://stackoverflow.com/questions/2741036/using-jinternalframe-and-some-jbutton/2741726#2741726). – trashgod Sep 10 '12 at 11:28
0

U can Display JFrame Forms on Click of Menu on Top of Parent Window.
U can make it act like a dialog by making the Parent Form disable and when Child Form Exits again we can Enable the parent Form.

Azuu
  • 836
  • 2
  • 16
  • 32
  • I am able to do that but I am not looking for the option, I want to display that in the Main window itself – Alwin Doss Sep 10 '12 at 09:04
  • 2
    U can make ur Forms on JPanel and load it on the Main Forms Container. or u can Use JInternalFrame. – Azuu Sep 10 '12 at 09:10
  • This works. Will you have an idea as to why a JFrame does not work in place of JPanel?? – Alwin Doss Sep 10 '12 at 09:17
  • 2
    @AlwinDoss *"why a JFrame does not work in place of JPanel??"* See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/a/9554657/418556) – Andrew Thompson Sep 10 '12 at 09:47
  • @AlwinDoss U cannot add External JFrame inside a Frame. u have to use JInternalFrame. – Azuu Sep 10 '12 at 10:29