Home | » | Java | » | Advance Java | » | Java Swing II | » | JSlide |
---|
Sliders that are implemented in Swing through the JSlider class enables a number to be set by sliding a control within the range of a minimum and maximum values. In many cases, a slider can be used for numeric input instead of a text field, and it has the advantage of restricting input to a range of acceptable values.
A Slider is often seen in media players to adjust the audio volume, channel frequencies, contrast or brightness of picture, and so on.
Sliders are horizontaly by default. The orientation can be explicity set by using two class variables of the SwingConstants class: HORIZONTAL or VERICAL.
The following are the JSlider constructor methods:
Slider component have an optional label that can be used to indicate the minimum value, maximum value and two different sets of tick marks rangining between the values.
The elements of this label are established by calling several methods of JSlider:
These methods should be called on the slider before it is added to a container.
Example:
The following displays a slider that can control the speed at which a picture is animated.
C:\>jdk1.4\bin>javac JSliderDemo.java
C:\>jdk1.4\bin>java JSliderDemo
|
||
Download Complete Program |
It is a wonderful article about the Java.
ReplyDeleteJava Training in OMR