How can set a specific CellEditor for one cell in a JTable?

devaki perumal

To do this, extend the class DefaultCellEditor and override the method

public Component getTableCellEditorComponent(JTable table,
                                             Object value,
                                             boolean isSelected,
                                             int row,
                                             int column)

if you want to edit the cell at (1,2), then in getTableCellEditorComponent check for whether the row is 1 and col is 2 then return the component to edit that cell; for other cells, return something different.

Then create an instance of the above class and set the cell editor of your table to this instance.

[FAQ Manager Note] An easier way to do this is to override isCellEditable(row,col) for your table model to return true only for the cells you want to edit. Set the cell editors you want for the columns in question. If you need to be able to edit more than one cell in a column, use the above technique to distinguish between editors in the column.