java - Fill a JComboBox with new values -


currently filling jcombobox that:

countrybox = new jcombobox(countrylist.toarray(new string[countrylist.size()])); 

however, when using program countrylist changes , fill jcombobox differently. tried use action change jcombobox:

countrybox.addactionlistener(new actionlistener() {    countrybox = new jcombobox(countrylist.toarray(new string[countrylist.size()])); } 

however, not change values. me seems countrybox prefilled data before. recommendations do?

i appreciate answer!

don't create new jcombobox, create new model

defaultcomboboxmodel model = new defaultcomboboxmodel(countrylist.toarray(new string[countrylist.size()])); countrybox.setmodel(model); 

you create own comboboxmodel proxy current list, that's you.

take closer @ how use combo boxes more details


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

Error while updating a record in APEX screen -

c++ - In an add-in in Excel, written in C(++), how does one get the name of the function which called into the addin? -