File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Row selections after sorting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Row selections after sorting " Watch "Row selections after sorting " New topic

Row selections after sorting

Mithun Chennuru

Joined: Dec 17, 2013
Posts: 13
I am having issues with keeping the row selection after sorting the data. That is, if I select result1 in row1 and sort the column, I still have row1 selected, but some other result, say result8 is in that row. How do I keep that selection locked to the result, instead of row?

Row selection

Sort method

I tried
but, this doesnt work.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2261
Don't attempt to manage this yourself. The built in JTable support will manage this for you.

Read the section from the Swing tutorial on Sorting and Filtering for a working example.
It is sorta covered in the JavaRanch Style Guide.
subject: Row selections after sorting