Java JScrollPane scrollToTop(final JScrollPane scrollPane)

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

Description

Scrolls scroll pane to the top left corner.

License

Open Source License

Declaration

public static void scrollToTop(final JScrollPane scrollPane) 

Method Source Code


//package com.java2s;
import javax.swing.JScrollPane;
import javax.swing.JScrollBar;

public class Main {
    /**//  w  w w  .  j a  v  a 2s . co  m
     * 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. newJScrollPane(String title, Component c)
  2. resetScrollPane(final JScrollPane scrollPane)
  3. scrollToBottom(final JScrollPane scrollPane)
  4. scrolltoHomePosition(JScrollPane jScrollPane1)
  5. scrollToTop(final JScrollPane scroller, int delay)
  6. scrollToTop(JScrollPane scrollPane)
  7. scrollToTopLater(final JScrollPane scrollPane)
  8. scrollToVisible(Component comp, JScrollPane parent)
  9. setDefaultScrollbarUnits(JScrollPane scrollPane)