JTable how prepareEditor works
I think the prepareRenderer(...)
code should be:
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
Component c = super.prepareRenderer(renderer, row, column);
if ((column == 2 || column == 3) && (Boolean)getValueAt(row, 0)) {
return c;
}
// if (column == 0 || column == 1 || (Boolean) getValueAt(row, 0)) {
if (column == 0 || column == 1) {
return c;
}
return Box.createRigidArea(c.getPreferredSize());
}
Then you should get rid of the prepareEditor(...)
code. Instead you should have more logic in the isCellEditable(...)
method. Something like:
public boolean isCellEditable(int row, int column) {
if (column == 0) return true;
if (column == 1 || column == 4 || column == 5) return false;
return (Boolean)getValueAt(row, 0);
}