Aug
20
|
There’s a method in JComponent called scrollRectToVisible() which interacts with the parent scroll pane (if one exists) to change its viewport. It takes a Rectangle as an argument that specifies the area you want to be visible in the viewport.
So for example to scroll to a given row in a JTable you would use something like this:
table.scrollRectToVisible( new Rectangle( 0, row * table.getRowHeight(), table.getWidth(), table.getRowHeight()));
Leave a Reply
You must be logged in to post a comment.