Skip to main content

modifying & adding data in JTable cells

1 reply [Last post]
abilliot
Offline
Joined: 2006-02-17

When i add data into an empty row of my table, the cursor stays in the last column. If i try to add that data to my list, the last column's data is invalid because the cursor is still on it and i guess it hasn't really been entered into the cell. I have to tab to the next row for it to work. The same thing happens when i try to modify data - i have to tab to the next column for the new data to "stick". Is there a way around this?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
shan-man
Offline
Joined: 2006-02-17

Hi,

abilliot wrote:
> When i add data into an empty row of my table, the
> cursor stays in the last column. If i try to add
> that data to my list, the last column's data is
> invalid because the cursor is still on it and i guess
> it hasn't really been entered into the cell. I have
> to tab to the next row for it to work. The same
> thing happens when i try to modify data - i have to
> tab to the next column for the new data to "stick".
> Is there a way around this?

The data isn't committed to the model automatically. To commit it, as you've seen, you need to move focus out of the cell. Or, you can hit ENTER.

It's possible that you could provide a custom cell editor that commits the data immediately, but I wouldn't recommend it. What you see now is what I beleive most users would expect. It also gives you a chance to hit ESCAPE to cancel/revert an edit.

Thanks,
Shannon