Keeping id's of list for JCombobox
807603Dec 2 2007 — edited Dec 3 2007Hi,
i'm filling a JCombobox with database values (Strings) of a table. Every string has an internal ID, which i use to store in other tables.. My problem is the following: i know i can detect what the user selected (getSelectedIndex() and getSelectedValue()), but what does that mean to me. GetSelectedIndex is only a number and GetSelectedValue is the text in de combobox, which i only a text i don't want to store. What i do want to know, is the internal ID behind that value. I don't want to retrieve my database again because i know the String of the table to get the internal ID.
I solved my problem by extending a JCombobox and keeping track of my internal ID's in a int[], but i don't know if this is the best solution.
Am I missing something? Is there a very simple solution for my problem?
Greetz
Peesjee