Java JScrollPane scrollToTopLater(final JScrollPane scrollPane)

Here you can find the source of scrollToTopLater(final JScrollPane scrollPane)

Description

Scrolls scroll pane to the top left corner a bit later.

License

Open Source License

Declaration

public static void scrollToTopLater(final JScrollPane scrollPane) 

Method Source Code


//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());
    }
}

Related

  1. scrollToBottom(final JScrollPane scrollPane)
  2. scrolltoHomePosition(JScrollPane jScrollPane1)
  3. scrollToTop(final JScrollPane scroller, int delay)
  4. scrollToTop(final JScrollPane scrollPane)
  5. scrollToTop(JScrollPane scrollPane)
  6. scrollToVisible(Component comp, JScrollPane parent)
  7. setDefaultScrollbarUnits(JScrollPane scrollPane)
  8. setScrollpane(JScrollPane scrollpane)
  9. setScrollPaneSize(JScrollPane scrollPane, int rows, int columns)