Reputation: 79
for example this is my JTable
:
ID|NAME|AGE
001|anna|18
002|tony|25
now i want that the user will enter the ID, then convert that ID into which row it belongs. now i'm using setRowSelectionInterval()
to select the row without really selecting it in the actual row. but i don't know how to get the data from a column, then convert it into a row where it belongs, so i can put in in the setRowSelectionInterval()
. thank you for any of your help :)
Upvotes: 0
Views: 38
Reputation: 324137
Write a loop.
You can use the getRowCount()
method of the table to iterate through each row.
Then you use the getValueAt(...)
method to get the value of the ID in the row for the specific column.
When you find a match you use the row index for the setRowSelectionInterval(...)
method.
Upvotes: 2