我使用 Netbeans
创建了一个 MasterDetail Simple Form
,并且我有一个与数据库相关的 JTable
。
我想编辑此 JTable
中的列,使其不可编辑。
我用 Google 搜索了一下,这是我能找到的所有内容:
this.masterTable.getColumn("Validation").setEditable(false);
这对我不起作用!
最佳答案
覆盖 TableModel 的 isCellEditable(...)
方法。
DefaultTableModel model = new DefaultTableModel(...)
{
@Override
public boolean isCellEditable(int row, int column)
{
// add your code here
}
}
JTable table = new JTable( model );
关于java - 在 JTable 中使列不可编辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16801382/