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
Post a Comment