0

If required I'll post an SSCCE.

I have a JTable with JComboBoxes @ First and Second Columns.

Upon a selection in the First Column JComboBox of a row, I want to update this row's Second Column JComboBox. (Chained Selections - I know how to do this with plain JComboBoxes but things go wrong with JTable)

I've tried getValueAt(int row, int col) method to change the CellEditor and dummy set the value as an empty string (like no selection), but it doesn't work properly. Doesn't properly update JComboBox and doesn't allow for selection and some other weird things.

Also, tried ItemListener for the First Column JComboBox but I can't find a way to properly update the Second Column JComboBox. I tried changing the CellEditor of the selected row, but it seems to be messing up with other rows as well, it's like more it remembers a previously selected row or something similar.

What is the proper way of doing chained selects in a JTable? I've been messing with this for almost a week..

Anton Hell
  • 53
  • 7

1 Answers1

0

In your case you should work with cell editors (your JCombobox). From editor you can get value from JCombobox and set this value to another JCombobox. In my opinion you can 1) get selected cell; 2) from cell you can get cell editor; 3) from editor (if editor is JCombobox you can get text field component and from this component you can get value, jCombobox must be editable in this case) you can get value.

alnasfire
  • 720
  • 6
  • 23