Java JTable - Make only one column editable

后端 未结 5 887
伪装坚强ぢ
伪装坚强ぢ 2020-12-06 05:36

I was wondering how to make one column of a JTable editable, the other columns have to be non editable.

I have overwritten isCellEditable() but this changes every ce

5条回答
  •  时光说笑
    2020-12-06 05:56

    Override the table model

    isCellEditable(int rowIndex, int columnIndex) takes two arguments, just return true for the column you want?

    public boolean isCellEditable(int rowIndex, int columnIndex){
    return columnIndex == 0; //Or whatever column index you want to be editable
    }
    

提交回复
热议问题