Java JScrollPane setDefaultScrollbarUnits(JScrollPane scrollPane)

Here you can find the source of setDefaultScrollbarUnits(JScrollPane scrollPane)

Description

Set reasonable unit increments for a scroll pane that does not contain a Scrollable.

License

Open Source License

Parameter

Parameter Description
scrollPane a parameter

Declaration

public static void setDefaultScrollbarUnits(JScrollPane scrollPane) 

Method Source Code


//package com.java2s;
/*/*from   w  ww  .j  a  va2  s.  co  m*/
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the license, or (at your option) any later version.
*/

import javax.swing.*;

public class Main {
    /**
     * Set reasonable unit increments for a scroll pane that does not contain a
     * <tt>Scrollable</tt>.
     *
     * @param scrollPane
     */
    public static void setDefaultScrollbarUnits(JScrollPane scrollPane) {

        int unit = new JLabel().getFont().getSize() * 2;
        scrollPane.getHorizontalScrollBar().setUnitIncrement(unit);
        scrollPane.getVerticalScrollBar().setUnitIncrement(unit);
    }
}

Related

  1. scrollToTop(final JScrollPane scroller, int delay)
  2. scrollToTop(final JScrollPane scrollPane)
  3. scrollToTop(JScrollPane scrollPane)
  4. scrollToTopLater(final JScrollPane scrollPane)
  5. scrollToVisible(Component comp, JScrollPane parent)
  6. setScrollpane(JScrollPane scrollpane)
  7. setScrollPaneSize(JScrollPane scrollPane, int rows, int columns)
  8. setUnitIncrement(JScrollPane scroller)
  9. show(JComponent comp, String windowName, boolean hasScrollBars, int x, int y, int width, int height)