How to set JscrollPane scroller position at the top?

If you are using JScrollPane to allow scrolling in a JFrame or any other component and you want the scroll bar back up to the top . You can use the following code to solve the purpose:


SwingUtilities.invokeLater(new Runnable() {
public void run() {
scrollPane.getViewport().setViewPosition(new java.awt.Point(0, 0));
}
});


If you want to increase the JScrollPane scrolling speed, you can read more information here
Share on Google Plus

About Pranav

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment