• Post Reply Bookmark Topic Watch Topic
  • New Topic

A Quick GUI Question

 
Inuka Jayasekera
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I don't know if this sounds like a silly thing to ask but if I want to replace a panel in a frame with another, do i call setVisible(false) for the first one and setVisible(true) for the second one? This method works but I will be having quite a few panels by the end of the application and was wandering if there is a better way of doing this....
Thank you... )
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch Inuka!
You can remove the previously added component with Container.remove(Component) , Container.remove(index) or Container.removeAll()
Remember to call Container.validate() afer adding the replacement Component.
 
Inuka Jayasekera
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for that.... huge help...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!