So I am adding rows to the JTable. I have a button outside the JTable for adding rows, so it is when I click the button that it will add a row and put the cursor into the first cell of that row. Each time I add a row it fires off the code twice. I added two rows, here is the output
So I think the second one is row number of the added row. The first two should not even appear as it added a row, which changes the row selected from -1 to 0. But it should have fired when adding the second row since I am "leaving" the first row.
Now when I am in the table and use the up and down arrows it only first once, which is good, but I am trying to get the exact row number that I just left, which it isn't because the Event has first and last index, but not the row that was "last edited"
Any help that can allow me to validate a row when you leave a row, whether you stay in the JTable or not.
In you example it looks like the validation is occured per cell rather than when leaving a row. Is this true? I want to do validation after leaving the row. The reason why is that the validation is just that the mandatory fields are filled in, not the values themselves.
And my last question is this
the row, is that the new row selected, or the one you just left?
Thanks for your help.
Joined: Jan 14, 2004
...validation is occured per cell rather than when leaving a row. Yes, I set this up to validate each cell. To validate a row for input fields you might consider making a one–row JTable as the row component and adding it to the table. I see that JTable supports InputVerifier which you might be able to use to verify the row table before focus is surrendered.
...is that the new row selected, or the one you just left? It's the new row selected.