This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JComboBox

 
kumar mars
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai
is there is any way to change the list displayed in the combobox dynamically
i want to change the whole list
i have a combo box that displays the available fonts this list of fonts have to change as language changes (change of language is done using another combo box)
can i assign a new list to display in the combo box
hoping an immediate help
 
Wilfried LAURENT
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You first have to put your encapsulate your list in a objet of a class implementing ComboBoxModel and call the setModel method on the instance of JComboBox.
W.
 
kumar mars
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can u please eloberate this
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
attach an item listener to the first combobox (displaying the languages). when the value gets changed it will call the itemchanged method. within this method you can reset the model of the second combo box. see the tutorial for detailed information (http://java.sun.com/docs/books/tutorial/uiswing/components/).
chantal
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic