This discussion is archived
1 Reply Latest reply: Sep 19, 2012 7:00 AM by StanislavL RSS

JComboBox selectedIndex and selectItem

Gage-Bollo Newbie
Currently Being Moderated
Hello,
I would just like to know if there is a work-around for this problem.

According to the javadoc, a JComboBox's getSelectedIndex returns the first item in the list that matches the given item, which is fine if you have unique items in the list. But what if you have the same items in a list, e.g "James", "James" but would like to select them according to their indexes in the list. Changing the index/selecting the item will select the first one, but if i want to select the second one, for any reason? Is there a work-around for this, without having to change the items (the names in my example)?

Thank you
Zweli

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points