JSlider Class
Package: javax.swing
The JSlider class creates a slider control, which lets a user pick a value from a set range (say, from 0 to 50) by moving a knob. A slider is a convenient way to get numeric input from the user when the input falls within a set range of values. Figure 5-10 shows a typical slider.

Figure 5-10
Constructors
|
Constructor |
Description |
|
|
Creates a new slider. The minimum and maximum values default to |
|
|
Creates a new slider with the specified minimum and maximum values. The initial value is halfway between the minimum and maximum. |
|
|
Creates a new slider with the specified minimum, maximum, and initial values. |
|
|
Creates a new slider with the specified minimum, maximum, and initial values. The orientation can be |
Methods
|
Method |
Description |
|
|
Adds a |
|
|
Gets the value indicated by the current position of the knob. |
|
|
Sets the font of the text associated with the slider. |
|
|
If |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access