• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamic JComboBox  RSS feed

 
Servin Park
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again,
I would like to dynamically populate 2nd JComboBox depending on the option chosen in the first JComboBox. For instance, comBo1 contains Fruit, Vegetable. If I select Fruit, comBo2 is populated with Apple, Pear, Peach... If I select Vegetable, comBo2 contains Onion, Lettus, Broccoli... Many Thanks in advance.
 
Snigdha Solanki
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have the code for this but have you tried using methods addItem(),removeAllItems() to make
the item list dynamic? Basically you can add ActionListener to JcomboBox and depending upon the selection in the first combo box dynamically set the item list in the second combo box.
 
Martin Schneider
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need something like this?

I asked sometimes same thing and I was given this and this was just what I needed.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!