JTable Data not saved

I have JTable in a GUI and a button to save the data in the table to a database. The JTable's view and model are separate. When I do a save, the data in the last cell which I edited is lost.

Only if I change the focus to a different cell or if I press ENTER key, it fires an event to update the cell (i.e. it calls the "setValue" method in the data model). Without this, how can I fire an event to update the data in the cell.
bonk1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vladi21Commented:
call cancelEditing()
0
vladi21Commented:
if (isEditing()) myDefaultCellEditor.cancelCellEditing();

or

 if (isEditing()) getDefaultEditor(String.class).cancelCellEditing();
0
bonk1Author Commented:
Calling cancelCellEditing causes the orgional value to be placed back into the cell that is currently being edited.  This does not call setValueAt() for my TableModel.

0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

bonk1Author Commented:
I think what I need to do is call fireEditingStopped() of the default cell editor. But that function is protected and I can't find information on how to properly setup a new DefaultCellEditor.
0
bonk1Author Commented:
Calling cancelCellEditing causes the orgional value to be placed back into the cell that is currently being edited.  This does not call setValueAt() for my TableModel.

0
bonk1Author Commented:
Ok here's the answer. It's not cancelCellEditing() but it's stopCellEditing().  Thanks, anyways.  I guess you pushed me in the right direction.

0
vladi21Commented:
yes its
stopCellEditing();

I have written it in the evening escaping with work and on a road has recollected that was not exact slightly
:)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.