I have a database schema = which will be shown in a JCombobox as a JTable column to select a name. But I want the ID field to insert (as a foreign key) in another table.
Usually, selecting an Item in drop down, bring the selected item to the shown area of the combo box.
What I want to do is, when select any item (string) in the combo box its corresponding integer key (can be kept in a sorted map) should be shown in the combobox placeholder area, so that when take the value of the JTable.getValueAt(row, column), I get the integer key, not the string item value.
Please help me how can I do that?
Since there is no automatic way to do it :(.
I am using a Map to keep my values and key.
Get all the categories (key, value) and populate the map and combo
The fourth column of my JTable should be combobox,
When editing the value in the combobox, it show the text, but for updating the value in the database table I have to get the integer key.
For database update,
And here is the getKeyForValue,