Hi there, JComboBox has a constructor that takes a Vector. this will be its dataModel. Say I have created the JComboBox and given it a Vector. If dynmically i add new Data to the Vector, how would I get the JComboBox to update to reflect the changes in data add? Any ideas? thanks , Sarone
The JComboBox has a method "addItem(Object anObject)", but this will work only if you have a data model that recognizes changes. I believe that the default model doesn't recognize changes. So you have two choices: 1) Write you own class that implements "ComboBoxModel" and use it, or 2) replace the entire data model every time you change the underlying data. This is done via:
Obviously "myComboBox" is your JComboBox instance, and "myData" is your new Vector (or Array) of data.