|
||||||||||
| 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 java.lang.Object ![]() |
|---|
clone |
| Field Detail |
|---|

protected BoundedRangeModel![]()
![]()
sliderModel

protected int majorTickSpacing

protected int minorTickSpacing
setMinorTickSpacing(int)


protected boolean snapToTicks
setSnapToTicks(boolean)


protected int orientation
setOrientation(int)


protected ChangeListener![]()
![]()
changeListener
addChangeListener(javax.swing.event.ChangeListener)
,
createChangeListener()


protected transient ChangeEvent![]()
![]()
changeEvent
ChangeEvent is needed per slider instance since the
event's only (read-only) state is the source property. The source
of events generated here is always "this". The event is lazily
created the first time that an event notification is fired.
fireStateChanged()

| Constructor Detail |
|---|

public JSlider()

public JSlider(int orientation)

public JSlider(int min,
int max)

public JSlider(int min,
int max,
int value)

public JSlider(int orientation,
int min,
int max,
int value)
IllegalArgumentException

- if orientation is not one of VERTICAL, HORIZONTALsetOrientation(int)
,
setMinimum(int)
,
setMaximum(int)
,
setValue(int)


public JSlider(BoundedRangeModel![]()
![]()
brm)
| Method Detail |
|---|

public SliderUI![]()
![]()
getUI()

public void setUI(SliderUI![]()
![]()
ui)
ui - the SliderUI L&F objectUIDefaults.getUI(javax.swing.JComponent)


public void updateUI()
updateUI

in class JComponent

JComponent.updateUI()


public String![]()
![]()
getUIClassID()
getUIClassID

in class JComponent

JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)


protected ChangeListener![]()
![]()
createChangeListener()
fireStateChanged()


public void addChangeListener(ChangeListener![]()
![]()
l)
l - the ChangeListener to addfireStateChanged()
,
removeChangeListener(javax.swing.event.ChangeListener)


public void removeChangeListener(ChangeListener![]()
![]()
l)
l - the ChangeListener to removefireStateChanged()
,
addChangeListener(javax.swing.event.ChangeListener)


public ChangeListener![]()
![]()
[] getChangeListeners()
ChangeListeners added
to this JSlider with addChangeListener().
ChangeListeners added or an empty
array if no listeners have been added

protected void fireStateChanged()
addChangeListener(javax.swing.event.ChangeListener)
,
EventListenerList


public BoundedRangeModel![]()
![]()
getModel()
setModel(javax.swing.BoundedRangeModel)


public void setModel(BoundedRangeModel![]()
![]()
newModel)
getModel()


public int getValue()
setValue(int)


public void setValue(int n)
getValue()


public int getMinimum()
setMinimum(int)


public void setMinimum(int minimum)
getMinimum()
,
BoundedRangeModel.setMinimum(int)


public int getMaximum()
setMaximum(int)


public void setMaximum(int maximum)
getMaximum()
,
BoundedRangeModel.setMaximum(int)


public boolean getValueIsAdjusting()
setValueIsAdjusting(boolean)


public void setValueIsAdjusting(boolean b)
getValueIsAdjusting()
,
BoundedRangeModel.setValueIsAdjusting(boolean)


public int getExtent()
setExtent(int)
,
BoundedRangeModel.getExtent()


public void setExtent(int extent)
getExtent()
,
BoundedRangeModel.setExtent(int)


public int getOrientation()
setOrientation(int)


public void setOrientation(int orientation)
IllegalArgumentException

- if orientation is not one of VERTICAL, HORIZONTALgetOrientation()


public Dictionary![]()
![]()
getLabelTable()
Dictionary containing labels and
where to draw them

public void setLabelTable(Dictionary![]()
![]()
labels)
{ Integer value, java.swing.JComponent label }.
createStandardLabels(int)
,
getLabelTable()


protected void updateLabelUIs()
JComponent.updateUI()


public Hashtable![]()
![]()
createStandardLabels(int increment)
createStandardLabels( 10 )
and the slider minimum is
zero, then it will make labels for the values 0, 10, 20, 30, and so on.
setLabelTable(java.util.Dictionary)


public Hashtable![]()
![]()
createStandardLabels(int increment, int start)
createStandardLabels( 10, 2 ),
then it will make labels for the values 2, 12, 22, 32, and so on.
IllegalArgumentException

- if slider label start point
out of range or if label increment is less than or equal
to zerosetLabelTable(java.util.Dictionary)


public boolean getInverted()
setInverted(boolean)


public void setInverted(boolean b)
ComponentOrientation property. Normal (non-inverted)
horizontal sliders with a ComponentOrientation value of
LEFT_TO_RIGHT have their maximum on the right.
Normal horizontal sliders with a ComponentOrientation value of
RIGHT_TO_LEFT have their maximum on the left. Normal vertical
sliders have their maximum on the top. These labels are reversed when the
slider is inverted.
b - true to reverse the slider values from their normal order

public int getMajorTickSpacing()
setMajorTickSpacing(int)


public void setMajorTickSpacing(int n)
getMajorTickSpacing()


public int getMinorTickSpacing()
getMinorTickSpacing()


public void setMinorTickSpacing(int n)
getMinorTickSpacing()


public boolean getSnapToTicks()
setSnapToTicks(boolean)


public void setSnapToTicks(boolean b)
b - true to snap the knob to the nearest tick markgetSnapToTicks()


public boolean getPaintTicks()
setPaintTicks(boolean)


public void setPaintTicks(boolean b)
getPaintTicks()


public boolean getPaintTrack()
setPaintTrack(boolean)


public void setPaintTrack(boolean b)
getPaintTrack()


public boolean getPaintLabels()
setPaintLabels(boolean)


public void setPaintLabels(boolean b)
getPaintLabels()


protected String![]()
![]()
paramString()
null.
paramString

in class JComponent


public AccessibleContext![]()
![]()
getAccessibleContext()
getAccessibleContext

in interface Accessible

getAccessibleContext

in class JComponent

|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||