1

I have a JTable with 4 columns and two JComboBoxes (Respectively on the first and second columns.).
The values of a JComboBox in the second column are filtered based on the selection of a value in the first column only on the same row.
The moment in which the emptying and restocking takes place is on the selection of the value of the first column.
The reciprocal setting is set up in this way:

self.fcaOrdinati.combo.addActionListener(self.filterFca)
self.fcaCombo = JComboBox([])
self.fcaOrdinati.mainTable.getColumnModel().getColumn(1).setCellEditor(DefaultCellEditor(self.fcaCombo))

Below there's the listener (which works and is triggered) with the retrieval of the selected row and the value of the first JComboBox (so up to here everything is ok)

def filterFca(self, e):
   selectedArt = self.fcaOrdinati.combo.getSelectedItem()
   selectedRow = self.fcaOrdinati.mainTable.getSelectedRow()
   """
      ??? How do I add items only to the JComboBox of this row ???
   """

So my question is... How do I add items only to the JComboBox of the selected row?? (I already know the column index, so it is a constant)
Thanks in advance!


EDIT: I also accept answers in Java, not just in jython.
The number of rows in the table is not fixed. The user chooses how many to add.

Memmo
  • 298
  • 3
  • 8
  • 31
  • By default the same editor is used by the entire column. If you want a different editor for each row in a given column then check out: https://stackoverflow.com/a/4211552/131872 for one approach. – camickr Oct 27 '20 at 14:25

0 Answers0