Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Combo Boxes

Status
Not open for further replies.

fatcodeguy

Programmer
Feb 25, 2002
281
CA
Hi! I want to make it so that I can change the vector for a JComboBox anytime, and the front end will update itself automatically. How do I do this?

Thanks
 
You'll want to create a ComboBoxModel object and then add a ListDataListener to pick up the changes to the model.
 
Thanks. Now how do I detect a change in the list. For example, I want two combo boxes. The first is a fixed list, and whatever they select in the first determines the content of the second list.
 
Ok. I got it to work without using a ListDataListener. The first ComboBox (the one that determines the other) has an ItemListener. So when you select different items, it will perform different actions. The second Combo Box is created with a model, which allows you to change the list and have it updated visually. Thus, in the ItemListener action definition, you can modify the model to have the second box display different items.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top