javax.swing
Class JSlider

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JSlider
All Implemented Interfaces:
Accessible, java.awt.image.ImageObserver, MenuContainer, Serializable, SwingConstants

public class JSlider
extends JComponent
implements SwingConstants, Accessible

Safe: 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. 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. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see java.beans.XMLEncoder.

Version:
1.97 12/03/01
Author:
David Kloba
See Also:
Serialized Form

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.
private  boolean isInverted
           
private  Dictionary labelTable
           
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
           
private  boolean paintLabels
           
private  boolean paintTicks
           
private  boolean paintTrack
           
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.
(package private)  boolean snapToValue
          If true, the knob (and the data value it represents) resolve to the closest slider value next to where the user positioned the knob.
private static String uiClassID
           
 
Fields inherited from class javax.swing.JComponent
_bounds, accessibleContext, listenerList, paintingChild, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
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
 
Constructor Summary
JSlider()
          Enabled: Creates a horizontal slider with the range 0 to 100 and an initial value of 50.
JSlider(BoundedRangeModel brm)
          Enabled: Creates a horizontal slider using the specified BoundedRangeModel.
JSlider(int orientation)
          Enabled: Creates a slider using the specified orientation with the range 0 to 100 and an initial value of 50.
JSlider(int min, int max)
          Enabled: 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)
          Enabled: Creates a horizontal slider using the specified min, max and value.
JSlider(int orientation, int min, int max, int value)
          Enabled: Creates a slider with the specified orientation and the specified minimum, maximum, and initial values.
 
Method Summary
 void addChangeListener(ChangeListener l)
          Enabled: Adds a ChangeListener to the slider.
private  void checkOrientation(int orientation)
           
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)
          Enabled: Creates a hashtable that will draw text labels starting at the slider minimum using the increment specified.
 Hashtable createStandardLabels(int increment, int start)
          Enabled: 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()
          Suppressed: Gets the AccessibleContext associated with this JSlider.
 ChangeListener[] getChangeListeners()
          Suppressed: Returns an array of all the ChangeListeners added to this JSlider with addChangeListener().
 int getExtent()
          Enabled: Returns the "extent" -- the range of values "covered" by the knob.
 boolean getInverted()
          Enabled: Returns true if the value-range shown for the slider is reversed,
 Dictionary getLabelTable()
          Enabled: Returns the dictionary of what labels to draw at which values.
 int getMajorTickSpacing()
          Enabled: This method returns the major tick spacing.
 int getMaximum()
          Enabled: Returns the maximum value supported by the slider.
 int getMinimum()
          Enabled: Returns the minimum value supported by the slider.
 int getMinorTickSpacing()
          Enabled: This method returns the minor tick spacing.
 BoundedRangeModel getModel()
          Enabled: Returns data model that handles the sliders three fundamental properties: minimum, maximum, value.
 int getOrientation()
          Enabled: Return this slider's vertical or horizontal orientation.
 boolean getPaintLabels()
          Enabled: Tells if labels are to be painted.
 boolean getPaintTicks()
          Enabled: Tells if tick marks are to be painted.
 boolean getPaintTrack()
          Enabled: Tells if the track (area the slider slides in) is to be painted.
 boolean getSnapToTicks()
          Enabled: 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.
(package private)  boolean getSnapToValue()
          Returns true if the knob (and the data value it represents) resolve to the closest slider value next to where the user positioned the knob.
 javax.swing.plaf.SliderUI getUI()
          Suppressed: Gets the UI object which implements the L&F for this component.
 String getUIClassID()
          Suppressed: Returns the name of the L&F class that renders this component.
 int getValue()
          Enabled: Returns the sliders value.
 boolean getValueIsAdjusting()
          Enabled: True if the slider knob is being dragged.
protected  String paramString()
          Returns a string representation of this JSlider.
 void removeChangeListener(ChangeListener l)
          Enabled: Removes a ChangeListener from the slider.
 void setExtent(int extent)
          Enabled: Sets the size of the range "covered" by the knob.
 void setInverted(boolean b)
          Enabled: 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)
          Enabled: Used to specify what label will be drawn at any given value.
 void setMajorTickSpacing(int n)
          Enabled: This method sets the major tick spacing.
 void setMaximum(int maximum)
          Enabled: Sets the models maximum property.
 void setMinimum(int minimum)
          Enabled: Sets the models minimum property.
 void setMinorTickSpacing(int n)
          Enabled: This method sets the minor tick spacing.
 void setModel(BoundedRangeModel newModel)
          Enabled: Sets the model that handles the sliders three fundamental properties: minimum, maximum, value.
 void setOrientation(int orientation)
          Enabled: Set the scrollbars orientation to either VERTICAL or HORIZONTAL.
 void setPaintLabels(boolean b)
          Enabled: Determines whether labels are painted on the slider.
 void setPaintTicks(boolean b)
          Enabled: Determines whether tick marks are painted on the slider.
 void setPaintTrack(boolean b)
          Enabled: Determines whether the track is painted on the slider.
 void setSnapToTicks(boolean b)
          Enabled: 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.
(package private)  void setSnapToValue(boolean b)
          Specifying true makes the knob (and the data value it represents) resolve to the closest slider value next to where the user positioned the knob.
 void setUI(javax.swing.plaf.SliderUI ui)
          Suppressed: Sets the UI object which implements the L&F for this component.
 void setValue(int n)
          Enabled: Sets the sliders current value.
 void setValueIsAdjusting(boolean b)
          Enabled: Sets the models valueIsAdjusting property.
protected  void updateLabelUIs()
          Resets the UI property to a value from the current look and feel.
 void updateUI()
          Suppressed: Resets the UI property to a value from the current look and feel.
private  void writeObject(ObjectOutputStream s)
          See readObject() and writeObject() in JComponent for more information about serialization in Swing.
 
Methods inherited from class javax.swing.JComponent
_paintImmediately, addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, alwaysOnTop, checkIfChildObscuredBySibling, componentInputMapChanged, computeVisibleRect, computeVisibleRect, compWriteObjectNotify, contains, createToolTip, disable, enable, enableSerialization, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getCreatedDoubleBuffer, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getManagingFocusBackwardTraversalKeys, getManagingFocusForwardTraversalKeys, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getWriteObjCounter, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyBindings, processKeyBindingsForAllComponents, processKeyEvent, processMouseMotionEvent, putClientProperty, rectangleIsObscured, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setCreatedDoubleBuffer, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPaintingChild, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, setWriteObjCounter, shouldDebugGraphics, superProcessMouseMotionEvent, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, get, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, iterate, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, size, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, toString, transferFocus, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

uiClassID

private static final String uiClassID
See Also:
getUIClassID(), JComponent.readObject(java.io.ObjectInputStream)

paintTicks

private boolean paintTicks

paintTrack

private boolean paintTrack

paintLabels

private boolean paintLabels

isInverted

private boolean isInverted

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)

snapToValue

boolean snapToValue
If true, the knob (and the data value it represents) resolve to the closest slider value next to where the user positioned the knob.


orientation

protected int orientation
See Also:
setOrientation(int)

labelTable

private Dictionary labelTable

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()
Enabled: Creates a horizontal slider with the range 0 to 100 and an initial value of 50.


JSlider

public JSlider(int orientation)
Enabled: 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)
Enabled: 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)
Enabled: Creates a horizontal slider using the specified min, max and value.


JSlider

public JSlider(int orientation,
               int min,
               int max,
               int value)
Enabled: Creates a slider with the specified orientation and the specified minimum, maximum, and initial values.

See Also:
setOrientation(int), setMinimum(int), setMaximum(int), setValue(int)

JSlider

public JSlider(BoundedRangeModel brm)
Enabled: Creates a horizontal slider using the specified BoundedRangeModel.

Method Detail

checkOrientation

private void checkOrientation(int orientation)

getUI

public javax.swing.plaf.SliderUI getUI()
Suppressed: 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(javax.swing.plaf.SliderUI ui)
Suppressed: 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()
Suppressed: 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()
Suppressed: 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)
Enabled: 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)
Enabled: Removes a ChangeListener from the slider.

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

getChangeListeners

public ChangeListener[] getChangeListeners()
Suppressed: Returns an array of all the ChangeListeners added to this JSlider with addChangeListener().

Returns:
all of the ChangeListeners 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()
Enabled: 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)
Enabled: Sets the model that handles the sliders three fundamental properties: minimum, maximum, value.

See Also:
getModel()

getValue

public int getValue()
Enabled: Returns the sliders value.

Returns:
the models value property
See Also:
setValue(int)

setValue

public void setValue(int n)
Enabled: Sets the sliders current value. This method just forwards the value to the model.

See Also:
getValue()

getMinimum

public int getMinimum()
Enabled: 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)
Enabled: Sets the models minimum property.

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

getMaximum

public int getMaximum()
Enabled: 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)
Enabled: Sets the models maximum property.

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

getValueIsAdjusting

public boolean getValueIsAdjusting()
Enabled: 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)
Enabled: 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()
Enabled: 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)
Enabled: 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()
Enabled: Return this slider's vertical or horizontal orientation.

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

setOrientation

public void setOrientation(int orientation)
Enabled: Set the scrollbars orientation to either VERTICAL or HORIZONTAL.

See Also:
getOrientation()

getLabelTable

public Dictionary getLabelTable()
Enabled: 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)
Enabled: 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)
Enabled: 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)
Enabled: 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(java.util.Dictionary)

getInverted

public boolean getInverted()
Enabled: 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)
Enabled: 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()
Enabled: 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)
Enabled: 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()
Enabled: 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)
Enabled: 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()
Enabled: 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)

getSnapToValue

boolean getSnapToValue()
Returns true if the knob (and the data value it represents) resolve to the closest slider value next to where the user positioned the knob.

Returns:
true if the value snaps to the nearest slider value, else false

setSnapToTicks

public void setSnapToTicks(boolean b)
Enabled: 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()

setSnapToValue

void setSnapToValue(boolean b)
Specifying true makes the knob (and the data value it represents) resolve to the closest slider value next to where the user positioned the knob. If the snapToTicks property has been set to true, the snap-to-ticks behavior will prevail.

Parameters:
b - true to snap the knob to the nearest slider value
See Also:
getSnapToValue(), setSnapToTicks(boolean)

getPaintTicks

public boolean getPaintTicks()
Enabled: 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)
Enabled: Determines whether tick marks are painted on the slider.

See Also:
getPaintTicks()

getPaintTrack

public boolean getPaintTrack()
Enabled: 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)
Enabled: Determines whether the track is painted on the slider.

See Also:
getPaintTrack()

getPaintLabels

public boolean getPaintLabels()
Enabled: 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)
Enabled: Determines whether labels are painted on the slider.

See Also:
getPaintLabels()

writeObject

private void writeObject(ObjectOutputStream s)
                  throws IOException
See readObject() and writeObject() in JComponent for more information about serialization in Swing.

Parameters:
s - the ObjectOutputStream in which to write
IOException

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()
Suppressed: 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


comments?