简体   繁体   English

如何检查JTable中的特定单元格是否正在编辑?

[英]How to check if a particular cell in JTable is being edited?

I should be able to check if a cell is being edited during mouse hover by passing the column and row: 我应该能够通过传递列和行来检查鼠标悬停期间是否正在编辑单元格:

TableCellEditor cellEditor = table.getCellEditor(rowPoint, colPoint);

In the above example cellEditor doesn't provide a way to check whether is in edit mode. 在上面的示例中, cellEditor不提供检查是否处于编辑模式的方法。

On the other hand, by checking table.isEditing() is not enough because it returns true if any one of the cells is being edited. 另一方面,通过检查table.isEditing()是不够的,因为如果正在编辑任何一个单元格,它返回true

The cell that is currently being edited: 当前正在编辑的单元格:

JTable.getEditingRow();
JTable.getEditingColumn();

These 2 methods return the index of the row and column that contains the cell currently being edited. 这两个方法返回包含当前正在编辑的单元格的行和列的索引。 If nothing is being edited, they return -1 . 如果没有编辑任何内容,则返回-1

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

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