如何允许用户编辑 JTable 中的单行?

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

JTable 应该只允许编辑选定的特定行。 table 的其余部分应该处于非 editable 模式。单击 "Edit" 按钮后,理想情况下应该只考虑行号并将其设为 editable。

覆盖 table 的 TableModel 和 return true 中的 isCellEditable() 以获得所需的行:

private static final int DESIRED_ROW = …;

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