Swing Jtable 添加checkbox列

1.在TableModel中设置列类型

@Override
public Class getColumnClass(int columnIndex) {
    return getValueAt(0, columnIndex).getClass();
}

2.重写jtable 的isCellEditable方法,否则复选框无法选中

@Override
   public boolean isCellEditable(int arg0, int arg1) {
        return getValueAt(arg0, arg1).getClass() == Boolean.class;
   }
原文地址:https://www.cnblogs.com/swbzmx/p/5605890.html