• Post Reply Bookmark Topic Watch Topic
  • New Topic

displaying different contents based on the menuitem selected on the same jpanel

 
darshan sure
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have this desktop application where the data has to be dispalyed in different ways(along with varied buttons and textfields) based on the Menuitem selection, in the same part of the JFrame

So I add jPanel1(has its own set of jtextfileds and button) ,jpanel2 and jpanel3 to dataDisplayPanel(a jPanel). And set them all as invisible. ---- Am using NetBeans IDE and I do all 'adding' in the 'Design' window

And set the child components of jpanel1,jpanel2,jpanel3 to visible based on the menu item selected by the user.

Everything works fine with setting things to visible to invisible.

This is the 1st time ever I am developing something like this so I just wanted to make sure that this was the right way to be doing such things..

any suggestion,advise is appreciated..

 
pete stein
Bartender
Posts: 1561
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best way to swap JPanels is to use a CardLayout. The best way to learn to code Swing is to jettison your NetBeans code generation and to do it all by hand.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pete stein wrote:The best way to swap JPanels is to use a CardLayout. The best way to learn to code Swing is to jettison your NetBeans code generation and to do it all by hand.

+1

This shows how to use a card layout http://java.sun.com/docs/books/tutorial/uiswing/layout/card.html
 
darshan sure
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all for your response..I got everything on cardLayout and it is pretty neat..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!