Hi. I have a frame with a table in it and when the user enters values into
it they are able to save the table. However if the user doesn't press enter
to set the last cell of data, and clicks on the save button, the data in the
cell is not added to the table model as the system doesn't know it has been
entered. Is there any way of automatically finishing the editing of the cell
and setting the data it contains to the data model, perhaps by a lost focus
method, i.e. when the table loses focus the table finalises any cell being
edited adds its data to the model?
Any help will be most appreciated.
"Dave Oxtoby" <d.oxtoby@lineone.net> wrote on Sun, 4 Apr 2004 13:27:54
+0100 in comp.lang.java.gui:
>Hi. I have a frame with a table in it and when the user enters values into
>it they are able to save the table. However if the user doesn't press enter
[quoted text clipped - 4 lines]
>method, i.e. when the table loses focus the table finalises any cell being
>edited adds its data to the model?
In the event handler for your save button, try this, or some variation
of it:
if(table.isEditing()) {
table.getCellEditor().stopCellEditing();
}

Signature
Check out QueryForm, a free, open source, Java/Swing-based
front end for relational databases.
http://qform.sourceforge.net