Example -- Applet with one slider

In this example, the applet has a single slider which takes values in the range 0 to 255. By default, the initial value of the slider is set to the middle value of the range when the slider is initially displayed.

Java Runtime Environment is required to properly see the Applet. Please check the following link

Listing 2.1.3 shows the source code for the above program.

The program has a single slider,  slider of type JSlider. The applet implements the ChangeListener for the drag events on the slider. The stateChanged method handles the events generated by the slider. The current value of the slider is obtained by invoking the getValue method on the slider object itself.