I need help, i am struck with in jtable updation. I am on deadline :(
I have a jtable and save button. table has two columns, one column is labels and other column is for providing values. The column which takes input has text fields and combo boxes. When i click on save, the data from table should get saved on sever side in a file and same file is ftp and data from that file is displayed in same jtable.
The problem is when i edit a cell, and leave this cell focussed the value is not picked.
If i remove focus( by selecting other non editable cell) from that cell, the value is updated.
After googling a lot, i found two solutions:
1. jtable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
2. jtable.getCellEditor().stopCellEditing()
I tried many things and many combinations of above solutions before calling saveData but none of the solution is permanent. below solution is working 80% of the time.
saveActionPerformed() {
//-----------------
if(jtable.isEditing()){
jtable.getCellEditor().stopCellEditing();
} else {
jtable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE)<br>
}
//-------------------
saveData(); //save data on server side and ftp the file and display again on screen<br>
}
saveData() {
//should i put opposite functions of above used code in order to put back those properties on the jtable again, for example
dislaydata();
jtable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE)<br>
}
Please let me know the possible solution. A very big thank you in advance. Sincere apology for poor indentation.