If drop-down table has more than one row with same value in value column, how can I choose any one of those rows? Currently it returns the first one of those rows. For illustrating my question please use ShrinkSearchableDemo. Add this code:
editableTableExComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
TableExComboBox source = (TableExComboBox) e.getSource();
int row = source.getSelectedIndex();
String symbol = (String) source.getTableModel().getValueAt(row, 0);
String name = (String) source.getTableModel().getValueAt(row, 1);
Integer volume = (Integer) source.getTableModel().getValueAt(row, 4);
System.out.println(symbol+", "+name+", "+volume);
}
}
});
And add this to DemoData as a second row:
new Object[]{"AA", "AA test", 32.88, 0.53, 1000000},
If you select the AA test I would expect printed on console: "AA, AA test, 1000000". However, it always prints "AA, ALCOA INC, 4156200". I could setValueColumnIndex(1) to make Name column to be the value column. But, it wouldn't resolve an issue if values in Symbol and Name columns are same and Volume is different. Basically, regardless of how many columns have duplicate values I want to be able to select any row among those duplicated if at least one of the.