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;
   }

 

posted @ 2016-06-22 09:14  swbzmx  阅读(5317)  评论(0编辑  收藏  举报