Aditi
Aditi

Reputation: 13

How do I allow the user to edit a single row in JTable?

The JTable should allow only a particular, selected row to be edited. The rest of the table should be in the non-editable mode. Upon clicking a an "Edit" button, it should ideally just take into consideration the row number and make it editable.

Upvotes: 0

Views: 595

Answers (1)

trashgod
trashgod

Reputation: 205875

Override isCellEditable() in your table's TableModel and return true for the desired row:

private static final int DESIRED_ROW = …;

@Override
public boolean isCellEditable(int row, int column) {
    return row == DESIRED_ROW;
}

Upvotes: 2

Related Questions