自己定义一个类继承DefaultTableModel
然后重载以下方法:
public boolean isCellEditable(int pRow, int pCol) {
return false;
}
就可以了!
只能选择,不能编辑!

解决方案 »

  1.   

    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
      

  2.   

    isCellSelected
    public boolean isCellSelected(int row,
                                  int column)Returns true if the cell at the specified position is selected.
    Parameters:
    row - the row being queried
    column - the column being queried
    Returns:
    true if the cell at index (row, column) is selected, where the first row and first column are at index 0
    isRowSelected
    public boolean isRowSelected(int row)Returns true if the row at the specified index is selected.
    Returns:
    true if the row at index row is selected, where 0 is the first row