new Slider( starting-value, minimum-value, maximum-value ) new Slider( starting-value, minimum-value, maximum-value, size ) new Slider( starting-value, minimum-value, maximum-value, orientation ) new Slider( starting-value, minimum-value, maximum-value, orientation, size )
A "Slider" is what is also sometimes called a scrollbar (in fact I would have called it a scrollbar but that name was already taken in the Java environment). When the user moves the scroll box in a Slider, the browser invokes a "scroll" event handling method and reports the "value" corresponding to the scroll boxes new position. To do this, Java must know the range of values you would like associated with the various positions at which the scroll box might be placed.
Accordingly, the "Slider" constructor method requires at least three integers as parameters. The first parameter determines the value to be used to determine the initial position of the scroll box. The next two parameters specify the minimum and maximum values associated with the scroll box. The minimum value is associated with the left end or bottom of the scroll region. The maximum value with the right or top.
Two addtional parameters may optionally be included. If desired a string describing the desired orientation of the Slider may be provided after the parameters controlling the slider's values. Allowable orientations are "Vertical" and "Horizontal". By default, "Horizontal" is used if either no orientation or an invalid orientation is provided. Finally, a "size" parameter may be included as the last parameter. This parameter must be an integer. It determines the width or height of the slider. By default a size of 100 is assumed.
void scroll( int newValue ) { ... } void scroll( Slider target, int newValue ) { ... }
The only event handling method associated with Sliders is "scroll". Scroll can be declared with either one or two parameters. An integer parameter must be included as the last parameter in the methods declaration. When any Slider is changed, the browser will invoke "scroll" passing the value associated with the new position of the scrollBox as the value of this integer parameter. Optionally, "scroll" may be declared to also expect as its first parameter the Slider that was changed.
someslider.setValue( integer-value );
The "setValue" method can be used to set a new value for a Slider. The position of the scroll box will be adjusted to reflect the new value. The new value should fall between the minimum and maximum associated with the Slider.
someslider.getValue( )
The "getValue" method returns the value associated with the current position of the scroll box in the Slider to which the method is applied.