Alex Rivera | Logout

How to Keep Track of row index when JTable has been sorted by the user?

Asked 2010-11-11T06:17:59.450
11

I have a JTable which has 1st row blank. Now when I sort the table based on a column by clicking on that column then the blank row goes at the bottom. If I insert something in the blank row and do the sorting then the row is placed accordingly. How do I keep track of its row index even when it is sorted. I need to access that row but if user does the sorting then i loose the row index as it is no more the 1st row.

Edit
Report

1 Answer

14

JTable.convertRowIndexToView() will return you an index of the row in the view based on its index in the model. JTable.convertRowIndexToModel() will do the opposite.

answered 2010-11-11T06:24:22.763

Your Answer