I am using DefaultTableModel as follows:
DefaultTableModel model = new DefaultTableModel (COLUMNS, 0 )
{
@Override
public boolean isCellEdita
You can create your own custom cell editor that joins all check boxes in a column in a ButtonGroup. here's how:
public class VeryComplicatedCellEditor extends DefaultCellEditor {
private ArrayList groups;
public getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
JCheckBox checkBox = new JCheckBox();
growToSize(column);
groups.get(column).add(checkBox);
return checkBox;
}
private growToSize(int size) {
groups.ensureCapacity(size);
while (groups.size() < size)
groups.add(new ButtonGroup());
}
}
There are some complications that come from the fact that we don't know how big the table is, which are mostly taken care of in the growToSize method.
The way this works is by maintaining a list of ButtonGroups, one for each column. The editor component for each cell is added to the button group for its column.