|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.JSlider
A component that lets the user graphically select a value by slding
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 the keyboard keys used by this component in the standard Look and Feel (L&F) renditions, see the JSlider key assignments.
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. A future release of Swing will provide support for long term persistence.
Inner Class Summary | |
protected class |
JSlider.AccessibleJSlider
The class used to obtain the accessible role for this object. |
Inner classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
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,
listenerList,
TOOL_TIP_TEXT_KEY,
ui,
UNDEFINED_CONDITION,
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
WHEN_FOCUSED,
WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT,
CENTER_ALIGNMENT,
LEFT_ALIGNMENT,
RIGHT_ALIGNMENT,
TOP_ALIGNMENT |
Fields inherited from interface javax.swing.SwingConstants |
BOTTOM,
CENTER,
EAST,
HORIZONTAL,
LEADING,
LEFT,
NORTH,
NORTH_EAST,
NORTH_WEST,
RIGHT,
SOUTH,
SOUTH_EAST,
SOUTH_WEST,
TOP,
TRAILING,
VERTICAL,
WEST |
Constructor Summary | |
JSlider()
Creates a horizontal slider with the range 0 to 100 and an intitial value of 50. |
|
JSlider(BoundedRangeModel brm)
Creates a horizontal slider using the specified BoundedRangeModel. |
|
JSlider(int orientation)
Creates a slider using the specified orientation with the range 0 to 100 and an intitial value of 50. |
|
JSlider(int min,
int max)
Creates a horizontal slider using the specified min and max with an intitial value of 50. |
|
JSlider(int min,
int max,
int value)
Creates a horizontal slider using the specified min, max and value. |
|
JSlider(int orientation,
int min,
int max,
int value)
Creates a slider with the specified orientation and the specified mimimum, maximum, and initial values. |
Method Summary | |
void |
addChangeListener(ChangeListener l)
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(int increment)
Creates a hashtable that will draw text labels starting at the slider minimum using the increment specified. |
Hashtable |
createStandardLabels(int increment,
int start)
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()
Get the AccessibleContext associated with this JComponent |
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, with the maximum value at the left end of a horizontal slider or at the bottom of a vertical one. |
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(ChangeListener l)
Removes a ChangeListener from the slider. |
void |
setExtent(int extent)
Sets the size of the range "covered" by the knob. |
void |
setInverted(boolean b)
Specify true to reverse the value-range shown for the slider so that the maximum value is at the left end of a horizontal slider or at the bottom of a vertical one. |
void |
setLabelTable(Dictionary labels)
Used to specify what label will be drawn at any given value. |
void |
setMajorTickSpacing(int n)
This method sets the major tick spacing. |
void |
setMaximum(int maximum)
Sets the models maximum property. |
void |
setMinimum(int minimum)
Sets the models minimum property. |
void |
setMinorTickSpacing(int n)
This method sets the minor tick spacing. |
void |
setModel(BoundedRangeModel newModel)
Sets the model that handles the sliders three fundamental properties: minimum, maximum, value. |
void |
setOrientation(int orientation)
Set the scrollbars orientation to either VERTICAL or HORIZONTAL. |
void |
setPaintLabels(boolean b)
Determines whether labels are painted on the slider. |
void |
setPaintTicks(boolean b)
Determines whether tick marks are painted on the slider. |
void |
setPaintTrack(boolean b)
Determines whether the track is painted on the slider. |
void |
setSnapToTicks(boolean b)
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(SliderUI ui)
Sets the UI object which implements the L&F for this component. |
void |
setValue(int n)
Sets the sliders current value. |
void |
setValueIsAdjusting(boolean b)
Sets the models valueIsAdjusting property. |
protected void |
updateLabelUIs()
Called internally to replace the label UIs with the latest versions from the UIFactory when the UIFactory notifies us via updateUI that the L&F has changed. |
void |
updateUI()
Notification from the UIFactory that the L&F has changed. |
Methods inherited from class java.awt.Container |
add,
add,
add,
add,
add,
addContainerListener,
addImpl,
countComponents,
deliverEvent,
doLayout,
findComponentAt,
findComponentAt,
getComponent,
getComponentAt,
getComponentAt,
getComponentCount,
getComponents,
getLayout,
insets,
invalidate,
isAncestorOf,
layout,
list,
list,
locate,
minimumSize,
paintComponents,
preferredSize,
print,
printComponents,
processContainerEvent,
processEvent,
remove,
remove,
removeAll,
removeContainerListener,
setCursor,
setLayout,
validate,
validateTree |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
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
protected transient ChangeEvent changeEvent
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)
setOrientation(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()
JComponent.updateUI()
public String getUIClassID()
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)
protected void fireStateChanged()
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)
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)
getOrientation()
public Dictionary getLabelTable()
public void setLabelTable(Dictionary labels)
createStandardLabels(int)
,
getLabelTable()
protected void updateLabelUIs()
updateUI
that the L&F has changed.JComponent.updateUI()
public Hashtable createStandardLabels(int increment)
setLabelTable(java.util.Dictionary)
public Hashtable createStandardLabels(int increment, int start)
setLabelTable(java.util.Dictionary)
public boolean getInverted()
public void setInverted(boolean b)
b
- true to reverse the slider values from their normal orderpublic 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
.public AccessibleContext getAccessibleContext()
|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |