0

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.

4

2 回答 2

4

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;
   }
}
于 2012-07-12T03:38:04.980 回答
1

您正在使用 NetBeans GUI 编辑器创建表。在表格中Properties > model,为模型选择所需的原点。例如,您可以将@Hunter 添加Mymodel到您的来源并选择Custom code

new MyModel(data, cols)

定制模型

于 2012-07-12T16:44:43.080 回答