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

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -