Only one line editable in JTable

I am trying to make a special kind of jtable. I want the whole table to NOT be edited by default. But when the user clicks on the line, then clicks the "Edit" button, this specific line is editable. and as soon as they separate the line, they no longer edit it.

How can I do it?

+3
source share
1 answer

To control which cells are editable, you need to extend the JTable or JTableModel (see calling the model in the example below) to ensure that this method from JTable returns true for all the cells in the row (s) you want to edit based on your specification.

  public boolean isCellEditable(int row, int column) {
      return getModel().isCellEditable(row, convertColumnIndexToModel(column));
  }

, TableCellEditors

+5

Source: https://habr.com/ru/post/1711231/


All Articles