当前位置: 技术问答>java相关
简单问题100分:如何使JTable的单元格(或行)可以选择而不能编辑??
来源: 互联网 发布时间:2015-03-02
本文导语: 如何使JTable的单元格(或行)可以选择而不能编辑??给个例子,谢谢! | 自己定义一个类继承DefaultTableModel 然后重载以下方法: public boolean isCellEditable(int pRow, int pCol) { return false; } ...
如何使JTable的单元格(或行)可以选择而不能编辑??给个例子,谢谢!
|
自己定义一个类继承DefaultTableModel
然后重载以下方法:
public boolean isCellEditable(int pRow, int pCol) {
return false;
}
就可以了!
只能选择,不能编辑!
然后重载以下方法:
public boolean isCellEditable(int pRow, int pCol) {
return false;
}
就可以了!
只能选择,不能编辑!
|
isCellEditable
public boolean isCellEditable(int row,
int column)Returns true if the cell at row and column is editable. Otherwise, invoking setValueAt on the cell will have no effect.
Note: The column is specified in the table view's display order, and not in the TableModel's column order. This is an important distinction because as the user rearranges the columns in the table, the column at a given index in the view will change. Meanwhile the user's actions never affect the model's column ordering.
Parameters:
row - the row whose value is to be queried
column - the column whose value is to be queried
Returns:
true if the cell is editable
public boolean isCellEditable(int row,
int column)Returns true if the cell at row and column is editable. Otherwise, invoking setValueAt on the cell will have no effect.
Note: The column is specified in the table view's display order, and not in the TableModel's column order. This is an important distinction because as the user rearranges the columns in the table, the column at a given index in the view will change. Meanwhile the user's actions never affect the model's column ordering.
Parameters:
row - the row whose value is to be queried
column - the column whose value is to be queried
Returns:
true if the cell is editable