简体   繁体   English

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

[英]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. JTable应该只允许编辑特定的选定行。 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: 在表的TableModel重写isCellEditable() ,并为所需的行返回true

private static final int DESIRED_ROW = …;

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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