|
Java™ by example!
|
|
|
How do I programmatically scroll a scrollable JTable to a specific cell or row?
The scrollRectToVisible method is the magic one you need. The code fragment below assumes that selectedColumn and selectedRow indicate the cell that you want to make sure is visible. If your rows/columns are not all the same height/width you will have to change the calculations, but the concept is the same.
table.scrollRectToVisible( new Rectangle(columnWidth*selectedColumn, table.getRowHeight()*(selectedRow), columnWidth, table.getRowHeight()));
|
Further Information
Author of answer:
Comments
Comments to this answer are only viewable by members. Login or become a member!
|
|
|
|
|