1

I have a JCombobox whose content is populated this way:

List<MyClass> l = getList();
for(MyClass ll : l)
  combo.addItem(ll.toString());
combo.setSelectedIndex(0);

Everything's ok till I click on combo in order to show item list: when I click selected item disappears (but list appears) when I select an item on list whole combobox disappears!! Why?

user1610075
  • 1,583
  • 3
  • 15
  • 32

2 Answers2

1
  1. For JComboBoxs (add, remove, manage) Items to use is the ComboBoxModel.

  2. JComboBox and its Model is based on arrays Vector<> or Object[], since Java2.

  3. All updates (JComboBox and its Model) must be done on Event Dispatch Thread.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
mKorbel
  • 109,525
  • 20
  • 134
  • 319
1

Problem was related to another problem I had and this answer Panel components disappear when I minimize frame

solved both!

Community
  • 1
  • 1
user1610075
  • 1,583
  • 3
  • 15
  • 32