• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamic panel

 
william brown
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I want to create a dynamic panel that contains a comboBox and an inner panel. Whenever I select a value from the combobox, the inner panel will change to display different things.

It looks like I have to use CardLayout. Do I have other alternative?.. maybe using any repainting or whatever methods available?
 
Joe Ess
Bartender
Posts: 9361
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use Container.remove() to remove things from the GUI, then add things in their place. Make sure you invoke vaidate() on the container to run the layout manager when you're done rearranging things.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think CardLayout is a good choice. I try to avoid removing and adding things to containers in these kinds of situations. Just a personal choice on my part.
 
william brown
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much. I've used the validate(), remove() things and it works well. But using card layout is also a good choice. I might change to that alternative if there is any problem with my program later.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!