Possible Duplicate:
How to make a JTable non-editable
I am developing an application using Netbeans.
I have generated a Report in a JTable format.
It works properly but the rows and colums are editable, and I would them to be non-editable.
Possible Duplicate:
How to make a JTable non-editable
I am developing an application using Netbeans.
I have generated a Report in a JTable format.
It works properly but the rows and colums are editable, and I would them to be non-editable.
In your table model you can override the isCellEditable()
method:
public class MyModel extends DefaultTableModel
{
public MyModel(Object[][] data, Object[] cols)
{
super(data, cols);
}
public boolean isCellEditable(int row, int col)
{
return false;
}
}
您正在使用 NetBeans GUI 编辑器创建表。在表格中Properties > model
,为模型选择所需的原点。例如,您可以将@Hunter 添加Mymodel
到您的来源并选择Custom code
:
new MyModel(data, cols)