简体   繁体   中英

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.

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM