public class JSlider extends JComponent implements SwingConstants, Accessible
The slider can show both
major tick marks, and minor tick marks between the major ones. The number of
values between the tick marks is controlled with
setMajorTickSpacing
and setMinorTickSpacing
.
Painting of tick marks is controlled by setPaintTicks
.
Sliders can also print text labels at regular intervals (or at
arbitrary locations) along the slider track. Painting of labels is
controlled by setLabelTable
and setPaintLabels
.
For further information and examples see How to Use Sliders, a section in The Java Tutorial.
Warning: Swing is not thread safe. For more information see Swing's Threading Policy.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeans™
has been added to the java.beans
package.
Please see XMLEncoder
.
Modifier and Type | Class | Description |
---|---|---|
protected class |
JSlider.AccessibleJSlider |
This class implements accessibility support for the
JSlider class. |
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field | Description |
---|---|---|
protected ChangeEvent |
changeEvent |
Only one
ChangeEvent is needed per slider instance since the
event's only (read-only) state is the source property. |
protected ChangeListener |
changeListener |
The changeListener (no suffix) is the listener we add to the
slider's model.
|
protected int |
majorTickSpacing |
The number of values between the major tick marks -- the
larger marks that break up the minor tick marks.
|
protected int |
minorTickSpacing |
The number of values between the minor tick marks -- the
smaller marks that occur between the major tick marks.
|
protected int |
orientation |
Whether the slider is horizontal or vertical
The default is horizontal.
|
protected BoundedRangeModel |
sliderModel |
The data model that handles the numeric maximum value,
minimum value, and current-position value for the slider.
|
protected boolean |
snapToTicks |
If true, the knob (and the data value it represents)
resolve to the closest tick mark next to where the user
positioned the knob.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION,