Is it possible, to define values different from the actual content in a JComboBox?
In HTML it looks as follows:
Assuming you have a class Person that holds the names and ids, you can add instances of this class as objects of the combo box. getSelectedItem()
will then return the instance of selected Person.
The problem is to display the person correctly in the combobox. You can either overload toString in the class to return the name, or you can supply your own ListCellRenderer
to the combo box and render whatever you wish (for example, photo thumbnails) in the combo box.