我正在为我的 JTable 使用以下单元模型:
this.setModel(new DefaultTableModel
(
new Object [][] {
{"Item ID", ""},
{"Radius", 0},
{"Center", 0,0},
{"Mass", 0}
},
new String []
{
"Property", "Value"
}
)
{
Class[] types = new Class []
{
String.class, Object.class
};
boolean[] canEdit = new boolean []
{
false, true
};
@Override
public Class getColumnClass(int columnIndex)
{
return types [columnIndex];
}
@Override
public boolean isCellEditable(int rowIndex, int columnIndex)
{
return canEdit [columnIndex];
}
});
但这会将整行和列设置为可编辑/不可编辑。如何将单个单元格(1,1)设置为不可编辑?