Java: What is the difference between block increment and unit increment and what are these values used for?

increment, java, jscrollbar, jscrollpane, swing

Solution

When working with `JScrollBar` you can actually scroll(move the `knob` of the scroll bar):

- by clicking the arrow button placed at the border of `JScrollBar`.

by clicking on the `track` upon which the `knob` is moving.

clicking on the button scrolls the visible area by a unit increment and the track scrolls the visible area by a block increment.

Are these values different by default on different operating systems?

The OS has nothing to do with these.

Problem

What is the difference between `block increment` and `unit increment` and what are these two values used for? These two fields/values are used by the `Adjustable` class. This class includes these four methods: ``` int getBlockIncrement(); int getUnitIncrement(); void setBlockIncrement(int b); void setUnitIncrement(int u); ``` The `JScrollBar` class for example implements this `Adjustable` class. These two values effect the behaviour of this scroll bar. So, what are these two values used for exactly? Also, how do these values affect the behaviour of the `JScrollBar` component. Are these values different by default on different operating systems?

Original source