![](/img/trans.png)
[英]How to set and get the cell value of JavaFX Table like swing JTable
[英]Java Swing: How can I get the previous value and the current value when editing a cell in JTable?
您可以使用TableCellListener来识别单元格数据何时发生实际更改,从而允许您使用tcl.getNewValue()
检索单元格的当前值(新值),以及使用tcl.getOldValue()
旧值. 此外,它还允许您获取已修改单元格的row
和column
索引。
如上面来源中给出的示例:
Action action = new AbstractAction()
{
public void actionPerformed(ActionEvent e)
{
TableCellListener tcl = (TableCellListener)e.getSource();
System.out.println("Row : " + tcl.getRow());
System.out.println("Column: " + tcl.getColumn());
System.out.println("Old : " + tcl.getOldValue());
System.out.println("New : " + tcl.getNewValue());
}
};
TableCellListener tcl = new TableCellListener(table, action); // where table is the instance of your JTable
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.