• Post Reply Bookmark Topic Watch Topic
  • New Topic

commonly accepted procedure for switching panels in a JFrame

 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am building an application with one JFrame. The user navigates to various "pages" that are really JPanels or other containers that get switched out with something like


Is this the commonly accepted way to do such a thing?
I just wanted to check if there is a reason not to do it this way and if I need to worry about destroying the existing panel manually when I replace it with a new one.
 
Shashank Agarwal
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I dont see any problem with that. And I dont think theres any standard procedure. You could also use the add() and remove() functions to display and hide the panels. I'm not sure how good would that be, but give it a try.
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think CardLayout is what you are looking for.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!