62,612
社区成员
发帖
与我相关
我的任务
分享
private class TableCellEditor extends DefaultCellEditor{
public TableCellEditor(JCheckBox checkBox) {
super(checkBox);
}
@Override
public Component getTableCellEditorComponent(JTable table,
Object value, boolean isSelected, int row, int column) {
JComponent comp = (JComponent) super.getTableCellEditorComponent(table, value, isSelected, row, column);
if(comp instanceof JCheckBox){
return comp;
}else{
if (column== 1) {
JCheckBox checkBox = new JCheckBox();
checkBox.setText("a");
return checkBox;
}
}
}
}
如果要用editor 在第一列替换为checkbox 这样写应该是可以得 再把这个editor加到table 上就好了