Forums Register Login

getValueAt doesn't pick up changes

+Pie Number of slices to send: Send
I am building a screen that has a JTable and a "save" button. The user can enter values in the cells of the JTable and press "save" to save them in the database.

Sometimes the user enters a value in a cell and presses the "save" button without tabbing off of that cell first. In this case, the getValueAt() method doesn't recognize that the cell's value has been changed.

Is there another method that I can use instead of getValueAt() to get the new changed value? Maybe reallyGetValueAt()?
+Pie Number of slices to send: Send
Does anybody know how to get the value in a cell even if the user hasn't pressed enter of tabbed off the cell yet? I imagine that is something that needs to be done a lot.
+Pie Number of slices to send: Send
This situation is a problem because until the user hits 'enter' or tabs out of the cell, the JTable doesn't know to update the model. If you look at the documentation for JTable, you will see that it has several methods to determine if it is being edited (isEditing()),the coordinates the edit is taking place (getEditingRow/Column) and what component is doing the editing (getEditingComponent()).
Wherever you do your "save" button logic, I'd check isEditing(). If it returns true, I'd use the other methods to determine the value the user typed in and update the model with it.
If you send is by car it's a shipment, but if by ship it's cargo. This tiny ad told me:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 659 times.
Similar Threads
Jtable Cell editing validations
Editing last cell in JTable
MultiLine JTable
JTable problem
JTable
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:04:57.