views:

576

answers:

1

I am trying to make a special kind of jtable. I want the entire table to by default be NOT editable. But when the user clicks a row, then clicks the "Edit" jbutton, that specific row is editable. and once they deslect the row its no longer editable.

How would I go about doing this?

+4  A: 

to control which cells are editable, you will need to extend either JTable or JTableModel (see the call to 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 editable based on your spec.

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

also take a look at this tutorial to learn about TableCellEditors

akf