|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object![]()
![]()
![]()
java.awt.Component
![]()
![]()
![]()
java.awt.Container
![]()
![]()
![]()
javax.swing.JComponent
![]()
![]()
![]()
javax.swing.JSlider
, MenuContainer
, Serializable
, Accessible
, SwingConstants

public class JSlider

, Accessible

A component that lets the user graphically select a value by sliding
a knob within a bounded interval. The slider can show both
major tick marks and minor tick marks between them. The number of
values between the tick marks is controlled with
setMajorTickSpacing and setMinorTickSpacing.
For further information and examples see How to Use Sliders, a section in The Java Tutorial.
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 JavaBeansTM
has been added to the java.beans package.
Please see XMLEncoder
.
| Nested Class Summary | |
|---|---|
protected class |
JSlider.AccessibleJSlider
This class implements accessibility support for the JSlider class. |
Nested classes/interfaces inherited from class javax.swing.JComponent ![]() |
|---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container ![]() |
|---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component ![]() |
|---|
Component.AccessibleAWTComponent |
| Field Summary | |
|---|---|
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 Sliders 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
|
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. |
Fields inherited from class javax.swing.JComponent ![]() |
|---|
accessibleContext |
Fields inherited from class java.awt.Component ![]() |
|---|
BOTTOM_ALIGNMENT |
Fields inherited from interface javax.swing.SwingConstants ![]() |
|---|
BOTTOM |
Fields inherited from interface java.awt.image.ImageObserver ![]() |
|---|
ABORT |
| Constructor Summary | |
|---|---|
JSlider
Creates a horizontal slider with the range 0 to 100 and an initial value of 50. |
|
JSlider
Creates a horizontal slider using the specified BoundedRangeModel. |
|
JSlider
Creates a slider using the specified orientation with the range 0 to 100 and an initial value of 50. |
|
JSlider
Creates a horizontal slider using the specified min and max with an initial value equal to the average of the min plus max. |
|
JSlider
Creates a horizontal slider using the specified min, max and value. |
|
JSlider
Creates a slider with the specified orientation and the specified minimum, maximum, and initial values. |
|
| Method Summary | |
|---|---|
void |
addChangeListener
Adds a ChangeListener to the slider. |
protected ChangeListener |
createChangeListener
Subclasses that want to handle model ChangeEvents differently can override this method to return their own ChangeListener implementation. |
Hashtable |
createStandardLabels
Creates a hashtable that will draw text labels starting at the slider minimum using the increment specified. |
Hashtable |
createStandardLabels
Creates a hashtable that will draw text labels starting at the start point specified using the increment specified. |
protected void |
fireStateChanged
Send a ChangeEvent, whose source is this Slider, to each listener. |
AccessibleContext |
getAccessibleContext
Gets the AccessibleContext associated with this JSlider. |
ChangeListener |
getChangeListeners
Returns an array of all the ChangeListeners added
to this JSlider with addChangeListener(). |
int |
getExtent
Returns the "extent" -- the range of values "covered" by the knob. |
boolean |
getInverted
Returns true if the value-range shown for the slider is reversed, |
Dictionary |
getLabelTable
Returns the dictionary of what labels to draw at which values. |
int |
getMajorTickSpacing
This method returns the major tick spacing. |
int |
getMaximum
Returns the maximum value supported by the slider. |
int |
getMinimum
Returns the minimum value supported by the slider. |
int |
getMinorTickSpacing
This method returns the minor tick spacing. |
BoundedRangeModel |
getModel
Returns data model that handles the sliders three fundamental properties: minimum, maximum, value. |
int |
getOrientation
Return this slider's vertical or horizontal orientation. |
boolean |
getPaintLabels
Tells if labels are to be painted. |
boolean |
getPaintTicks
Tells if tick marks are to be painted. |
boolean |
getPaintTrack
Tells if the track (area the slider slides in) is to be painted. |
boolean |
getSnapToTicks
Returns true if the knob (and the data value it represents) resolve to the closest tick mark next to where the user positioned the knob. |
SliderUI |
getUI
Gets the UI object which implements the L&F for this component. |
String |
getUIClassID
Returns the name of the L&F class that renders this component. |
int |
getValue
Returns the sliders value. |
boolean |
getValueIsAdjusting
True if the slider knob is being dragged. |
protected String |
paramString
Returns a string representation of this JSlider. |
void |
removeChangeListener
Removes a ChangeListener from the slider. |
void |
setExtent
Sets the size of the range "covered" by the knob. |
void |
setInverted
Specify true to reverse the value-range shown for the slider and false to put the value range in the normal order. |
void |
setLabelTable
Used to specify what label will be drawn at any given value. |
void |
setMajorTickSpacing
This method sets the major tick spacing. |
void |
setMaximum
Sets the models maximum property. |
void |
setMinimum
Sets the models minimum property. |
void |
setMinorTickSpacing
This method sets the minor tick spacing. |
void |
setModel
Sets the model that handles the sliders three fundamental properties: minimum, maximum, value. |
void |
setOrientation
Set the scrollbars orientation to either VERTICAL or HORIZONTAL. |
void |
setPaintLabels
Determines whether labels are painted on the slider. |
void |
setPaintTicks
Determines whether tick marks are painted on the slider. |
void |
setPaintTrack
Determines whether the track is painted on the slider. |
void |
setSnapToTicks
Specifying true makes the knob (and the data value it represents) resolve to the closest tick mark next to where the user positioned the knob. |
void |
setUI
Sets the UI object which implements the L&F for this component. |
void |
setValue
Sets the sliders current value. |
void |
setValueIsAdjusting
Sets the models valueIsAdjusting property. |
protected void |
updateLabelUIs
Resets the UI property to a value from the current look and feel. |
void |
updateUI
Resets the UI property to a value from the current look and feel. |
Methods inherited from class javax.swing.JComponent ![]() |
|---|
addAncestorListener |