问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/1042144/only-one-row-editable-on-jtable