I have 2 JComboBox components added to my GUI productComboBox and categoryComboBox, with the following item listeners defined for each:
categoryComboBox.addItemListener(new GoItemListener());
productComboBox.addItemListener(new ProductItemListener());
The user first selects a product, and then the listener should populate the category box dependent on which product is selected. My item listeners are inner classes.
ProductItemListener calls a method populateCategories which looks like this:
protected void populateCategories() {
String product = productComboBox.getSelectedItem().toString();
myMediaDataAccessor.init(product);
ArrayList categoryArrayList = null;
categoryArrayList = myMediaDataAccessor.getCategories();
Iterator iterator = categoryArrayList.iterator();
String aCategory;
while (iterator.hasNext()) {
aCategory = (String) iterator.next();
categoryComboBox.addItem(aCategory.toString());
}
}
I have two product items in my productComboBox, Music and Videos. If I select Music then my categoryComboBox gets populated correctly with the strings from the ArrayList.
The problem is, if i select Videos, my categoryArrayList contains the correct ArrayList of strings, so my data is being returned and seemingly added to the categoryComboBox as I'm not getting any exceptions, its just that my categoryComboBox disappears from the GUI.
Any ideas?
Thanks