Java JTable - Make only one column editable

后端 未结 5 881
伪装坚强ぢ
伪装坚强ぢ 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 06:00

    JXTable/TableColumnExt of the SwingX project have api to configure editability per-table and per-column

     // make the table completely read-only
     xTable.setEditable(false);
     // make a column read-only
     xTable.getColumnExt(index).setEditable(false);
    

    Note that it is only possible to narrow the editability compared to that returned by model.isCellEditable. That is you can make a editable cell read-only but not the other way round

提交回复
热议问题