Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| JavaTM 2 Platform Standard Ed. 5.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.swing
Class JSlider

    java.lang.Object
      java.awt.Component
          java.awt.Container
              javax.swing.JComponent
                  javax.swing.JSlider

All Implemented Interfaces:
  ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants

    public class JSlider

extends JComponent
implements SwingConstants, 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, Component.BltBufferStrategy, Component.FlipBufferStrategy`

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, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST`

Fields inherited from interface java.awt.image.ImageObserver
`ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH`

Constructor Summary
`JSlider()` Creates a horizontal slider with the range 0 to 100 and an initial 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 initial value of 50.
`JSlider(int min, int max)` Creates a horizontal slider using the specified min and max with an initial value equal to the average of the min plus max.
`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 minimum, 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()` Gets the AccessibleContext associated with this JSlider.
`ChangeListener[]` | `getChangeListeners()` Returns an array of all the `ChangeListener`s 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(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 and false to put the value range in the normal order.
`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()` 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, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update`

Methods inherited from class java.awt.Container
`add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree`

Methods inherited from class java.awt.Component
`action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### 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 values between the major tick marks -- the larger marks that break up the minor tick marks.

### minorTickSpacing

    protected int minorTickSpacing

  The number of values between the minor tick marks -- the smaller marks that occur between the major tick marks.

  See Also:
    `setMinorTickSpacing(int)`

### 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. The default is false.

  See Also:
    `setSnapToTicks(boolean)`

### orientation

    protected int orientation

See Also:
  `setOrientation(int)`

### 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(javax.swing.event.ChangeListener)`, `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()`

Constructor Detail

### JSlider

    public JSlider()

  Creates a horizontal slider with the range 0 to 100 and an initial value of 50.

### JSlider

    public JSlider(int orientation)

  Creates a slider using the specified orientation with the range 0 to 100 and an initial value of 50.

### JSlider

    public JSlider(int min,
                   int max)

  Creates a horizontal slider using the specified min and max with an initial value equal to the average of the min plus max.

### JSlider

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

  Creates a horizontal slider using the specified min, max and value.

### JSlider

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

  Creates a slider with the specified orientation and the specified minimum, maximum, and initial values.

  Throws:
    `IllegalArgumentException` - if orientation is not one of VERTICAL, HORIZONTAL
  See Also:
    `setOrientation(int)`, `setMinimum(int)`, `setMaximum(int)`, `setValue(int)`

### JSlider

    public JSlider(BoundedRangeModel brm)

  Creates a horizontal slider using the specified BoundedRangeModel.

Method Detail

### 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:
    `UIDefaults.getUI(javax.swing.JComponent)`

### updateUI

    public void updateUI()

  Resets the UI property to a value from the current look and feel.

  Overrides:
    `updateUI` in class `JComponent`
  See Also:
    `JComponent.updateUI()`

### getUIClassID

    public String getUIClassID()

  Returns the name of the L&F class that renders this component.

  Overrides:
    `getUIClassID` in class `JComponent`
  Returns:
    "SliderUI"
  See Also:
    `JComponent.getUIClassID()`, `UIDefaults.getUI(javax.swing.JComponent)`

### 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(javax.swing.event.ChangeListener)`

### removeChangeListener

    public void removeChangeListener(ChangeListener l)

  Removes a ChangeListener from the slider.

  Parameters:
    `l` - the ChangeListener to remove
  See Also:
    `fireStateChanged()`, `addChangeListener(javax.swing.event.ChangeListener)`

### getChangeListeners

    public ChangeListener[] getChangeListeners()

  Returns an array of all the `ChangeListener`s added to this JSlider with addChangeListener().

  Returns:
    all of the `ChangeListener`s added or an empty array if no listeners have been added
  Since:
    1.4

### 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(javax.swing.event.ChangeListener)`, `EventListenerList`

### getModel

    public BoundedRangeModel getModel()

  Returns data model that handles the sliders three fundamental properties: minimum, maximum, value.

  See Also:
    `setModel(javax.swing.BoundedRangeModel)`

### 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(int)`

### 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(int)`

### setMinimum

    public void setMinimum(int minimum)

  Sets the models minimum property.

  See Also:
    `getMinimum()`, `BoundedRangeModel.setMinimum(int)`

### getMaximum

    public int getMaximum()

  Returns the maximum value supported by the slider.

  Returns:
    the value of the models maximum property
  See Also:
    `setMaximum(int)`

### setMaximum

    public void setMaximum(int maximum)

  Sets the models maximum property.

  See Also:
    `getMaximum()`, `BoundedRangeModel.setMaximum(int)`

### getValueIsAdjusting

    public boolean getValueIsAdjusting()

  True if the slider knob is being dragged.

  Returns:
    the value of the models valueIsAdjusting property
  See Also:
    `setValueIsAdjusting(boolean)`

### 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()`, `BoundedRangeModel.setValueIsAdjusting(boolean)`

### getExtent

    public int getExtent()

  Returns the "extent" -- the range of values "covered" by the knob.

  Returns:
    an int representing the extent
  See Also:
    `setExtent(int)`, `BoundedRangeModel.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()`, `BoundedRangeModel.setExtent(int)`

### getOrientation

    public int getOrientation()

  Return this slider's vertical or horizontal orientation.

  Returns:
    VERTICAL or HORIZONTAL
  See Also:
    `setOrientation(int)`

### 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.swing.JComponent label }`.

  See Also:
    `createStandardLabels(int)`, `getLabelTable()`

### updateLabelUIs

    protected void updateLabelUIs()

  Resets the UI property to a value from the current look and feel.

  See Also:
    `JComponent.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(java.util.Dictionary)`

### 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.

  Throws:
    `IllegalArgumentException` - if slider label start point out of range or if label increment is less than or equal to zero
  See Also:
    `setLabelTable(java.util.Dictionary)`

### getInverted

    public boolean getInverted()

  Returns true if the value-range shown for the slider is reversed,

  Returns:
    true if the slider values are reversed from their normal order
  See Also:
    `setInverted(boolean)`

### setInverted

    public void setInverted(boolean b)

  Specify true to reverse the value-range shown for the slider and false to put the value range in the normal order. The order depends on the slider's `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.

  Parameters:
    `b` - true to reverse the slider values from their normal order

### getMajorTickSpacing

    public int getMajorTickSpacing()

  This method returns the major tick spacing. The number that is returned represents the distance, measured in values, between each major tick mark. If you have a slider with a range from 0 to 50 and the major tick spacing is set to 10, you will get major ticks next to the following values: 0, 10, 20, 30, 40, 50.

  Returns:
    the number of values between major ticks
  See Also:
    `setMajorTickSpacing(int)`

### setMajorTickSpacing

    public void setMajorTickSpacing(int n)

  This method sets the major tick spacing. The number that is passed-in represents the distance, measured in values, between each major tick mark. If you have a slider with a range from 0 to 50 and the major tick spacing is set to 10, you will get major ticks next to the following values: 0, 10, 20, 30, 40, 50.

  See Also:
    `getMajorTickSpacing()`

### getMinorTickSpacing

    public int getMinorTickSpacing()

  This method returns the minor tick spacing. The number that is returned represents the distance, measured in values, between each minor tick mark. If you have a slider with a range from 0 to 50 and the minor tick spacing is set to 10, you will get minor ticks next to the following values: 0, 10, 20, 30, 40, 50.

  Returns:
    the number of values between minor ticks
  See Also:
    `getMinorTickSpacing()`

### setMinorTickSpacing

    public void setMinorTickSpacing(int n)

  This method sets the minor tick spacing. The number that is passed-in represents the distance, measured in values, between each minor tick mark. If you have a slider with a range from 0 to 50 and the minor tick spacing is set to 10, you will get minor ticks next to the following values: 0, 10, 20, 30, 40, 50.

  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(boolean)`

### 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()

  Tells if tick marks are to be painted.

  Returns:
    true if tick marks are painted, else false
  See Also:
    `setPaintTicks(boolean)`

### setPaintTicks

    public void setPaintTicks(boolean b)

  Determines whether tick marks are painted on the slider.

  See Also:
    `getPaintTicks()`

### getPaintTrack

    public boolean getPaintTrack()

  Tells if the track (area the slider slides in) is to be painted.

  Returns:
    true if track is painted, else false
  See Also:
    `setPaintTrack(boolean)`

### setPaintTrack

    public void setPaintTrack(boolean b)

  Determines whether the track is painted on the slider.

  See Also:
    `getPaintTrack()`

### getPaintLabels

    public boolean getPaintLabels()

  Tells if labels are to be painted.

  Returns:
    true if labels are painted, else false
  See Also:
    `setPaintLabels(boolean)`

### setPaintLabels

    public void setPaintLabels(boolean b)

  Determines whether labels are painted on the slider.

  See Also:
    `getPaintLabels()`

### paramString

    protected String paramString()

  Returns a string representation of this JSlider. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be `null`.

  Overrides:
    `paramString` in class `JComponent`
  Returns:
    a string representation of this JSlider.

### getAccessibleContext

    public AccessibleContext getAccessibleContext()

  Gets the AccessibleContext associated with this JSlider. For sliders, the AccessibleContext takes the form of an AccessibleJSlider. A new AccessibleJSlider instance is created if necessary.

  Specified by:
    `getAccessibleContext` in interface `Accessible`
  Overrides:
    `getAccessibleContext` in class `JComponent`
  Returns:
    an AccessibleJSlider that serves as the AccessibleContext of this JSlider

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| JavaTM 2 Platform Standard Ed. 5.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.