2015-06-21 65 views
0

我直接将数据插入到JTable中,假设JTable中有5行,我插入了所有值,最后我在第五行的单元格中插入值,并且单元格处于在这种情况下,我无法读取该单元格的数据。无法从JTable可编辑单元格读取数据

+0

您应该添加一些代码,以便我们可以知道您正在尝试做什么...... –

+0

您是从程序角度讲话还是使用视角?请记住 - 您必须在GUI中以用户身份离开单元,以便能够从程序端读取它。只需点击最后一个单元格外的某个地方,即可完成编辑,程序可以读取数据。 – Alex

回答

0

之前设置或JTable必须取消从细胞获得价值/停止editing.You可以通过

做到这一点假设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(); 

或varaible名

/** 
* Tells the editor to cancel editing and not accept any partially 
* edited value. 
*/ 
jTable1.getCellEditor().cancelCellEditing(); 
相关问题