Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com

Essential.

These are used .

In the constructor the scrollbar instance is created,....

its orientation,

the position of the scrolling knob ( the thumb ) and the size of the knob, that is used also as up/down value, when you click next to it.

the minimum and maximum value.

The slider is created.

Minimum, maximum.

Starting value.

Intervals.

Plus numbers.

The label is created, too, with its text centered.

Then, because this is an applet, the init method is called. Here, the contentpane's layout mode is set, so it is divided up into 5 rows of equal height .

The Scrollbar is added first, so it will take up the first row .

The moment it is used, the scrollbar will call the adjustmentValueChanged method,....

because this applet instance has been added to the scrollbar as an adjustmentListener.

This is allowed, because the class is said to implement the proper interface ....

and hereby guarantees the presence of this method.

This technique is ONLY NEEDED when you want to act the MOMENT the bar is USED. In most cases, you'll inspect its value later on, say, in an actionPerformed method.

In this example, we ask the scrollbar for its current value, when it is used.

We set the label's text to that value .

The value is used to set the contentpane's color to a shade of red.

A similar technique for the slider, but a different interface.

=======

NOTES

=======

The BorderLayout can also be used for adding a Scrollbar ( SOUTH, EAST etc. ).

.