- Code: Select all
// setting the combobox to the specific column of the table:
alertPropertiesTable
.getColumnModel()
.getColumn(2)
.setCellEditor(
new AlertComboBoxCellEditor(new JComboBox(
numberCriteria)));
// custom cell editor
private class AlertComboBoxCellEditor extends DefaultCellEditor implements
TableCellEditor {
private AlertComboBoxCellEditor(final JComboBox comboBox) {
super(comboBox);
}
@Override
public Component getTableCellEditorComponent(final JTable table,
final Object value, final boolean isSelected, final int row,
final int column) {
final JComboBox comboBox = (JComboBox) super
.getTableCellEditorComponent(table, value, isSelected, row,
column);
if (!entryPanel.hasChanges()) {
entryPanel.setChanged(true);
}
comboBox.setBorder(BorderFactory.createLineBorder(Color.black));
comboBox.setSelectedItem(value);
return comboBox;
}
}
Thanks.