Search code examples
javaswingjtablejcomboboxtablemodel

Return JComboBox from JTable


so I've got a number of JComboBox's which make up a JTable. My question is; without having access to these JComboBox's directly, how can I obtain them from the JTable? Below is how I've put the JComboBoxes into the JTable...

TableColumn columnModel = table.getColumnModel().getColumn(i);
columnModel.setCellEditor(new DefaultCellEditor(combo));

...So I would imagine that you can return them by doing something like...

JComboBox retrievedDropDowns = (JComboBox)table.getColumnModel().getColumn(1).getCellEditor();

But apparently not...

Am I far off?

Thanks!


Solution

  • Try:

    JComboBox retrievedDropDowns = (JComboBox)table.getColumnModel().getColumn(i).getCellEditor().getComponent();