R
Ramon F Herrera
I am looking for a way to associate a JComboBox to a *dynamic*
(growing) list of contents.
What I have so far is this:
(1) Read the items one at a time and add them to an ArrayList like
this:
placeList.add(item);
(2) After the above loop is done, convert the ArrayList to a fixed
length array:
int howMany = placeList.size();
String[] placeArray = new String[howMany];
placeList.toArray(placeArray);
(3) Finally, I can create a new ComboBox, which seems to prefer
fixed-length lists:
dropDownList = new DefaultComboBoxModel(placeArray));
Due to some other considerations, the above method has become very
inconvenient, and I would definitely prefer to bind the JComboBox to an
ArrayList (or anything else that is allowed to grow).
Thanks for your kind assistance.
-Ramon F Herrera
(growing) list of contents.
What I have so far is this:
(1) Read the items one at a time and add them to an ArrayList like
this:
placeList.add(item);
(2) After the above loop is done, convert the ArrayList to a fixed
length array:
int howMany = placeList.size();
String[] placeArray = new String[howMany];
placeList.toArray(placeArray);
(3) Finally, I can create a new ComboBox, which seems to prefer
fixed-length lists:
dropDownList = new DefaultComboBoxModel(placeArray));
Due to some other considerations, the above method has become very
inconvenient, and I would definitely prefer to bind the JComboBox to an
ArrayList (or anything else that is allowed to grow).
Thanks for your kind assistance.
-Ramon F Herrera