Actually there are two ways to select an entry of a combo box: 1. setSelectedIndex(int index) 2. setSelectedItem(Object obj)
So if you use the second one with the parameter "Tex" java gets every record of the JComboBox as an object and then calls the toString() method on them. He finds out the first time he finds "Tex" that they are equal so he selects that one.
Obviously you should use the first method knowing ofcorse the place of the second "Tex". If you don't then search it up through the combo box using a loop among with the method getItemAt(int index).
Behind the 2 'Tax' labels you must put 2 different objects, otherwise makes no sense to have the same entry twice. What I do in this situation I select based on the real object and use a custom renderer.
Hmm, a bug. I agree. Thing is, when the user selects an entry, I am not programmically selecting the object, the combo box is doing it. The only way I can think of round this is to include the index number in the text.
How come the same exact text appears in the combo twice? Is there not some context difference between the two? You could include this context in the combo to differentiate them (it may help the user out as well).