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,563
  • 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
  • 200,320
  • 28
  • 229
  • 974
mKorbel
  • 109,107
  • 18
  • 130
  • 305
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,563
  • 3
  • 15
  • 32