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;
}
}
You are using the NetBeans GUI editor to create your table. In the table's Properties > model
, select the desired origin for the model. For example, you can add @Hunter's Mymodel
to your source and choose Custom code
:
new MyModel(data, cols)