I have a JTable with few columns that are painted as checkboxes. What I want to do is to enable/disable checkbox from Column A by checking/unchecking corresponding checkbox in Column B.
I have managed to do it basing on this example, but I have a problem with newly enabled/disabled checkboxes - they are not refreshing properly. Checkbox which was enabled/disabled last is refreshed only after I click on any other cell in the table.
Problem looks like this ("Ref. structure" column is the one with enabled/disabled checkboxes):
Checkbox not enabled:
Checkbox not disabled:
This is my JTable code:
public class StructuresJTable extends JTable {
public StructuresJTable() {
super();
}
public StructuresJTable(TableModel dm) {
super(dm);
}
@Override
public Component prepareRenderer(TableCellRenderer renderer, int row,
int col) {
Component c = super.prepareRenderer(renderer, row, col);
if (col == StructuresTableModel.COMPARISON_REF_STRUCT_COL) {
c.setEnabled((Boolean) this.dataModel.getValueAt(row,
StructuresTableModel.COMPARE_COL));
} else {
c.setEnabled(true);
}
return c;
}
}
Do you have any suggestions how to make it work?