[英]How do I get the original value of a JTable cell in a TableModelEvent?
Let's say I change a cell with value "old" to "new". 假设我将值“旧”的单元格更改为“新”。 This will invoke tableChanged(TableModelEvent).
这将调用tableChanged(TableModelEvent)。 How do I retrieve the value that the cell had before "new"(which should be "old")?
如何检索单元格在“新”(应为“旧”)之前的值?
I thought about making a copy of TableModel of my JTable,but is there a simpler and smarter way to do this? 我曾考虑过制作JTable的TableModel副本,但是有没有更简单,更聪明的方法呢?
Thanks in advance! 提前致谢!
Try this when your table loads first time
int row1=table.getRowCount();
int column=table.getColumnCount();
val=new Object[row1];
val1=new Object[row1];
for(int j=0;j<row1;j++){
val[j]=table.getValueAt(j, 0);
val1[j]=table.getValueAt(j, 1);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.