All Packages Class Hierarchy This Package Previous Next Index
Class com.sun.java.swing.JSlider
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----com.sun.java.swing.JComponent
|
+----com.sun.java.swing.JSlider
- public class JSlider
- extends JComponent
- implements SwingConstants, Accessible
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
pixels between the tick marks is controlled with
setMajorTickSpacing
and setMinorTickSpacing
.
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 Swing1.0 applications. It will
not be possible to load serialized Swing1.0 objects with future releases
of Swing. The JDK1.2 release of Swing will be the compatibility
baseline for the serialized form of Swing objects.
-
changeEvent
- Only one ChangeEvent is needed per slider instance since the
event's only (read-only) state is the source property.
-
changeListener
- The changeListener (no suffix) is the listener we add to the
Sliders model.
-
majorTickSpacing
- The number of pixels between the major tick marks -- the
larger marks that break up the minor tick marks.
-
minorTickSpacing
- The number of pixels between the minor tick marks -- the
smaller marks that occur between the major tick marks.
-
orientation
-
-
sliderModel
- The data model that handles the numeric maximum value,
minimum value, and current-position value for the slider.
-
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.
-
JSlider()
- Creates a horizontal slider with the range 0 to 100 and
an intitial value of 50.
-
JSlider(int, int, int, int)
- Creates a slider with the specified orientation and the
specified mimimum, maximum, and initial values.
-
addChangeListener(ChangeListener)
- Adds a ChangeListener to the slider.
-
createChangeListener()
- Subclasses that want to handle model ChangeEvents differently
can override this method to return their own ChangeListener
implementation.
-
createStandardLabels(int)
- Creates a hashtable that will draw text labels starting at the slider minimum using the
increment specified.
-
createStandardLabels(int, int)
- Creates a hashtable that will draw text labels starting at the start point
specified using the increment specified.
-
fireStateChanged()
- Send a ChangeEvent, whose source is this Slider, to
each listener.
-
getAccessibleContext()
- Get the AccessibleContext associated with this JComponent
-
getExtent()
-
-
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.
-
getLabelTable()
- Returns the dictionary of what labels to draw at which values.
-
getMajorTickSpacing()
-
-
getMaximum()
- Returns the maximum value supported by the slider.
-
getMinimum()
- Returns the minimum value supported by the slider.
-
getMinorTickSpacing()
-
-
getModel()
- Returns data model that handles the sliders three
fundamental properties: minimum, maximum, value.
-
getOrientation()
-
-
getPaintLabels()
-
-
getPaintTicks()
-
-
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.
-
getUI()
- Gets the UI object which implements the L&F for this component.
-
getUIClassID()
- Returns the name of the L&F class that renders this component.
-
getValue()
- Returns the sliders value.
-
getValueIsAdjusting()
- True if the slider knob is being dragged.
-
removeChangeListener(ChangeListener)
- Removes a ChangeListener from the slider.
-
setExtent(int)
- Sets the size of the range "covered" by the knob.
-
setInverted(boolean)
- 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.
-
setLabelTable(Dictionary)
- Used to specify what label will be drawn at any given value.
-
setMajorTickSpacing(int)
- Sets the number of pixels between major tick marks.
-
setMaximum(int)
- Sets the models maximum property.
-
setMinimum(int)
- Sets the models minimum property.
-
setMinorTickSpacing(int)
- Sets the number of pixels between minor tick marks.
-
setModel(BoundedRangeModel)
- Sets the model that handles the sliders three
fundamental properties: minimum, maximum, value.
-
setOrientation(int)
- Set the scrollbars orientation to either VERTICAL or HORIZONTAL.
-
setPaintLabels(boolean)
- Determines whether labels are painted on the slider.
-
setPaintTicks(boolean)
- Determines whether tick marks are painted on the slider.
-
setSnapToTicks(boolean)
- 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.
-
setUI(SliderUI)
- Sets the UI object which implements the L&F for this component.
-
setValue(int)
- Sets the sliders current value.
-
setValueIsAdjusting(boolean)
- Sets the models valueIsAdjusting property.
-
toString()
- Returns a string containing that displays and identifies this
object's propeties.
-
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.
-
updateUI()
- Notification from the UIFactory that the L&F has changed.
sliderModel
protected BoundedRangeModel sliderModel
- The data model that handles the numeric maximum value,
minimum value, and current-position value for the slider.
majorTickSpacing
protected int majorTickSpacing
- The number of pixels between the major tick marks -- the
larger marks that break up the minor tick marks.
minorTickSpacing
protected int minorTickSpacing
- The number of pixels between the minor tick marks -- the
smaller marks that occur between the major tick marks.
- See Also:
- setMinorTickSpacing
snapToTicks
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.
- See Also:
- setSnapToTicks
orientation
protected int orientation
- See Also:
- setOrientation
changeListener
protected ChangeListener changeListener
- The changeListener (no suffix) is the listener we add to the
Sliders model. By default this listener just forwards events
to ChangeListeners (if any) added directly to the slider.
- See Also:
- addChangeListener, createChangeListener
changeEvent
protected transient ChangeEvent changeEvent
- Only one 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.
- See Also:
- fireStateChanged
JSlider
public JSlider(int orientation,
int min,
int max,
int value)
- Creates a slider with the specified orientation and the
specified mimimum, maximum, and initial values.
- Throws: IllegalArgumentException
- if orientation is not one of VERTICAL, HORIZONTAL
- See Also:
- setOrientation, setMinimum, setMaximum, setValue
JSlider
public JSlider()
- Creates a horizontal slider with the range 0 to 100 and
an intitial value of 50.
getUI
public SliderUI getUI()
- Gets the UI object which implements the L&F for this component.
- Returns:
- the SliderUI object that implements the Slider L&F
setUI
public void setUI(SliderUI ui)
- Sets the UI object which implements the L&F for this component.
- Parameters:
- ui - the SliderUI L&F object
- See Also:
- getUI
updateUI
public void updateUI()
- Notification from the UIFactory that the L&F has changed.
Called to replace the UI with the latest version from the
default UIFactory.
- Overrides:
- updateUI in class JComponent
- See Also:
- updateUI
getUIClassID
public String getUIClassID()
- Returns the name of the L&F class that renders this component.
- Returns:
- "SliderUI"
- Overrides:
- getUIClassID in class JComponent
- See Also:
- getUIClassID, getUI
createChangeListener
protected ChangeListener createChangeListener()
- Subclasses that want to handle model ChangeEvents differently
can override this method to return their own ChangeListener
implementation. The default ChangeListener just forwards
ChangeEvents to the ChangeListeners added directly to the slider.
- See Also:
- fireStateChanged
addChangeListener
public void addChangeListener(ChangeListener l)
- Adds a ChangeListener to the slider.
- Parameters:
- l - the ChangeListener to add
- See Also:
- fireStateChanged, removeChangeListener
removeChangeListener
public void removeChangeListener(ChangeListener l)
- Removes a ChangeListener from the slider.
- Parameters:
- l - the ChangeListener to remove
- See Also:
- fireStateChanged, addChangeListener
fireStateChanged
protected void fireStateChanged()
- Send a ChangeEvent, whose source is this Slider, to
each listener. This method method is called each time
a ChangeEvent is received from the model.
- See Also:
- addChangeListener, EventListenerList
getModel
public BoundedRangeModel getModel()
- Returns data model that handles the sliders three
fundamental properties: minimum, maximum, value.
- See Also:
- setModel
setModel
public void setModel(BoundedRangeModel newModel)
- Sets the model that handles the sliders three
fundamental properties: minimum, maximum, value.
- See Also:
- getModel
getValue
public int getValue()
- Returns the sliders value.
- Returns:
- the models value property
- See Also:
- setValue
setValue
public void setValue(int n)
- Sets the sliders current value. This method just forwards
the value to the model.
- See Also:
- getValue
getMinimum
public int getMinimum()
- Returns the minimum value supported by the slider.
- Returns:
- the value of the models minimum property
- See Also:
- setMinimum
setMinimum
public void setMinimum(int minimum)
- Sets the models minimum property.
- See Also:
- getMinimum, setMinimum
getMaximum
public int getMaximum()
- Returns the maximum value supported by the slider.
- Returns:
- the value of the models maximum property
- See Also:
- setMaximum
setMaximum
public void setMaximum(int maximum)
- Sets the models maximum property.
- See Also:
- getMaximum, setMaximum
getValueIsAdjusting
public boolean getValueIsAdjusting()
- True if the slider knob is being dragged.
- Returns:
- the value of the models valueIsAdjusting property
- See Also:
- setValueIsAdjusting
setValueIsAdjusting
public void setValueIsAdjusting(boolean b)
- Sets the models valueIsAdjusting property. Slider look and
feel implementations should set this property to true when
a knob drag begins, and to false when the drag ends. The
slider model will not generate ChangeEvents while
valueIsAdjusting is true.
- See Also:
- getValueIsAdjusting, setValueIsAdjusting
getExtent
public int getExtent()
- Returns:
- the range of values "covered" by the knob.
- See Also:
- setExtent, getExtent
setExtent
public void setExtent(int extent)
- Sets the size of the range "covered" by the knob. Most look
and feel implementations will change the value by this amount
if the user clicks on either side of the knob.
- See Also:
- getExtent, setExtent
getOrientation
public int getOrientation()
- Returns:
- VERTICAL or HORIZONTAL
- See Also:
- setOrientation
setOrientation
public void setOrientation(int orientation)
- Set the scrollbars orientation to either VERTICAL or HORIZONTAL.
- Throws: IllegalArgumentException
- if orientation is not one of VERTICAL, HORIZONTAL
- See Also:
- getOrientation
getLabelTable
public Dictionary getLabelTable()
- Returns the dictionary of what labels to draw at which values.
- Returns:
- the Dictionary containing labels and where to draw them
setLabelTable
public void setLabelTable(Dictionary labels)
- Used to specify what label will be drawn at any given value.
The key-value pairs are of this format: { Integer value, java.awt.Component label }
- See Also:
- createStandardLabels, getLabelTable
updateLabelUIs
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.
- See Also:
- updateUI
createStandardLabels
public Hashtable createStandardLabels(int increment)
- Creates a hashtable that will draw text labels starting at the slider minimum using the
increment specified. If you call createStandardLabels( 10 ) and the slider minimum is
zero, then it will make labels for the values 0, 10, 20, 30, and so on.
- See Also:
- setLabelTable
createStandardLabels
public Hashtable createStandardLabels(int increment,
int start)
- Creates a hashtable that will draw text labels starting at the start point
specified using the increment specified. If you call createStandardLabels( 10, 2 ),
then it will make labels for the values 2, 12, 22, 32, and so on.
- See Also:
- setLabelTable
getInverted
public 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.
- Returns:
- true if the slider values are reversed from their normal order
setInverted
public 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. Specify false to put the value range
in the normal order.
- Parameters:
- b - true to reverse the slider values from their normal order
getMajorTickSpacing
public int getMajorTickSpacing()
- Returns:
- the number of pixels between major ticks
- See Also:
- setMajorTickSpacing
setMajorTickSpacing
public void setMajorTickSpacing(int n)
- Sets the number of pixels between major tick marks.
- See Also:
- getMajorTickSpacing
getMinorTickSpacing
public int getMinorTickSpacing()
- Returns:
- the number of pixels between minor ticks
- See Also:
- getMinorTickSpacing
setMinorTickSpacing
public void setMinorTickSpacing(int n)
- Sets the number of pixels between minor tick marks.
- See Also:
- getMinorTickSpacing
getSnapToTicks
public 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.
- Returns:
- true if the value snaps to the nearest tick mark, else false
- See Also:
- setSnapToTicks
setSnapToTicks
public 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.
- Parameters:
- b - true to snap the knob to the nearest tick mark
- See Also:
- getSnapToTicks
getPaintTicks
public boolean getPaintTicks()
- Returns:
- true if tick marks are painted, else false
- See Also:
- setPaintTicks
setPaintTicks
public void setPaintTicks(boolean b)
- Determines whether tick marks are painted on the slider.
- See Also:
- getPaintTicks
getPaintLabels
public boolean getPaintLabels()
- Returns:
- true if labels are painted, else false
- See Also:
- setPaintLabels
setPaintLabels
public void setPaintLabels(boolean b)
- Determines whether labels are painted on the slider.
- See Also:
- getPaintLabels
toString
public String toString()
- Returns a string containing that displays and identifies this
object's propeties.
- Overrides:
- toString in class Component
getAccessibleContext
public AccessibleContext getAccessibleContext()
- Get the AccessibleContext associated with this JComponent
- Returns:
- the AccessibleContext of this JComponent
- Overrides:
- getAccessibleContext in class JComponent
All Packages Class Hierarchy This Package Previous Next Index