Automatically scroll to the selected row in JTable/JScrollPane

I have a program that populates values in a JTable, then sets then selected row. That works fine, but if the number of rows visible without scrolling is say 10 for example, and the the selected row of the table is 90, you need to either scroll manually to see the selection, or press up arrow key, to scroll semi-automatically. Is it possible to have the JScrollPane automatically scroll the the proper position to display the selected row of the JTable?

Thank you.
r0ckteacherAsked:
Who is Participating?
 
objectsConnect With a Mentor Commented:
table.scrollRectToVisible(table.getCellRect(row, 0, false));
0
 
girionisCommented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.