Here you can find the source of scrollToTopLater(final JScrollPane scrollPane)
public static void scrollToTopLater(final JScrollPane scrollPane)
//package com.java2s; import javax.swing.JScrollPane; import javax.swing.JScrollBar; import javax.swing.SwingUtilities; public class Main { /**/*from ww w. j a v a 2s. c o m*/ * Scrolls scroll pane to the top left corner a bit later. * @see #scrollToTop(JScrollPane) */ public static void scrollToTopLater(final JScrollPane scrollPane) { SwingUtilities.invokeLater(new Runnable() { public void run() { scrollToTop(scrollPane); } }); } /** * Scrolls scroll pane to the top left corner. */ public static void scrollToTop(final JScrollPane scrollPane) { JScrollBar verticalScrollBar = scrollPane.getVerticalScrollBar(); JScrollBar horizontalScrollBar = scrollPane.getHorizontalScrollBar(); verticalScrollBar.setValue(verticalScrollBar.getMinimum()); horizontalScrollBar.setValue(horizontalScrollBar.getMinimum()); } }