I need my combo box to have short names of organizations. The problem is i can see organizations names in dropdown list, but cant actually
I suspect it's that your setSelectedItem()
method compares objects using ==
rather than .equals()
Consider using a DefaultComboBoxModel which already implements useful methods.
Edit:
Also according to the Docs you should be calling all registered ListDataListener
objects when setSelected is called.
Using a DefaultComboBoxModel
is fairly straightforward. You create a new DefaultComboBoxModel
add the elements you want it to contain then call getSelectedItem()
to retrieve the element that is currently selected.