[英]Unable to read data from JTable editable cell
我直接在JTable中插入数据,假设JTable中有5行并且我全部插入了值,最后我在第五行的单元格中插入了值,并且该单元格处于可编辑模式,在这种情况下,我无法从中读取数据该单元格。
在设置或从JTable
的单元格中获取值之前,必须先取消/停止编辑。
假设jTable1
是JTable
的可变名称
/**
* Tells the editor to stop editing and accept any partially edited
* value as the value of the editor. The editor returns false if
* editing was not stopped; this is useful for editors that validate
* and can not accept invalid entries.
*
* @return true if editing was stopped; false otherwise
*/
jTable1.getCellEditor().stopCellEditing();
要么
/**
* Tells the editor to cancel editing and not accept any partially
* edited value.
*/
jTable1.getCellEditor().cancelCellEditing();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.