1、做一个modelpublic class DataTableModel extends AbstractTableModel2、实现
/**
* Returns true if the cell at rowIndex and columnIndex is editable.
* Otherwise, setValueAt on the cell will not change the value of that cell.
*
* @param row - The row whose value to be queried.
* @param col - The column whose value to be queried.
* @return boolean - True if the cell is editable.
*/
public boolean isCellEditable(int row, int col)3、引用
DataTableModel model = new DataTableModel();
jTable1.setModel(model);以上是个人的做法!请指正!
/**
* Returns true if the cell at rowIndex and columnIndex is editable.
* Otherwise, setValueAt on the cell will not change the value of that cell.
*
* @param row - The row whose value to be queried.
* @param col - The column whose value to be queried.
* @return boolean - True if the cell is editable.
*/
public boolean isCellEditable(int row, int col)3、引用
DataTableModel model = new DataTableModel();
jTable1.setModel(model);以上是个人的做法!请指正!
在public boolean isCellEditable(int row, int col)里这样:
return editables[col];
public boolean isCellEditable(int row, int col)
{
return editables[col];
}
这样就定义了第2,3列不可编辑,第0,1,4列可编辑
想怎么设就怎么设