Class AbstractMultiSlider<T>
- Type Parameters:
 T- the type of values that theAbstractMultiSliderstores and returns
- All Implemented Interfaces:
 ImageObserver,MenuContainer,Serializable
- Direct Known Subclasses:
 CategorialMultiSlider,LinearMultiSlider,MultiSlider
AbstractMultiSlider forms the base of implementing a slider with multiple thumbs. The AbstractMultiSlider is
 implemented by drawing a number of sliders on top of each other using an Swing OverlayManager, and passing the mouse
 events from a glass pane on top to the correct slider(s). The class is a ChangeListener to listen to the changes of
 individual sliders underneath.
 Several models exist to indicate whether thumbs can pass each other or not, or be on top of each other or not.
 The AbstractMultiSlider stores all values internally as int. Only when getting or setting values (or, e.g., the
 minimum or maximum), the generic type T is used.
 
Copyright (c) 2024-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.
- Author:
 - Alexander Verbraeck
 - See Also:
 
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classThe DispatcherPane class, which is a glass pane sitting on top of the sliders to dispatch the mouse event to the correct slider class.static interfaceThe FinalValueChangeListener sends a final value to the listeners after mouse-up, leave focus, setValue(...), and setInitialValues().protected static classThe LabelPanel is draw above a horizontal slider or left of a vertical slider and displays labels for the thumbs of the slider, so one can see which one is which.Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy - 
Field Summary
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH - 
Constructor Summary
ConstructorsConstructorDescriptionAbstractMultiSlider(int minIndex, int maxIndex, boolean horizontal, int... initialIndexValues) Creates a slider with the specified orientation and the specified minimum, maximum, and initial values. - 
Method Summary
Modifier and TypeMethodDescriptionvoidaddChangeListener(ChangeListener listener) Adds a ChangeListener to the multislider.voidAdds a FinalValueChangeListener to the multislider.protected voidRecalculate the track size (width for horizontal slider; height for vertical slider) after a resize operation.protected booleanCheck restrictions on all thumb values and correct values where necessary.protected booleancheckRestrictions(int index) Check restrictions on the thumb values of thumb 'index' and correct values where necessary.createStandardLabels(int increment) Creates aHashtableof numerical text labels, starting at the slider minimum, and using the increment specified.createStandardLabels(int increment, int startIndex) Creates aHashtableof text labels, starting at the starting point specified, and using the increment specified.protected voidSend aChangeEvent, whose source is thisMultiSlider, to allFinalValueChangeListeners that have registered interest inChangeEvents.protected voidSend aChangeEvent, whose source is thisMultiSlider, to allChangeListeners that have registered interest inChangeEvents.protected StringFormat a value for e.g., the labels of the slider.protected intReturn which slider is busy (e.g., mouse-down or a drag operation).Returns an array of all theChangeListeners added to this MultiSlider with addChangeListener().protected AbstractMultiSlider.DispatcherPaneReturn the glass pane on top of the multislider.intReturns the "extent" from theBoundedRangeModel.Returns an array of all theFinalValueChangeListeners added to this MultiSlider with addFinalValueChangeListener().protected intReturns the maximum value supported by the slider from theBoundedRangeModel.protected intReturns the minimum value supported by the slider from theBoundedRangeModel.intgetIndexValue(int i) Returns the slider's current index value for slider[i] from theBoundedRangeModel.booleanReturns true if the value-range shown for the slider is reversed.protected AbstractMultiSlider.LabelPanelReturn the label panel in which thumb labels can be drawn.Returns the dictionary of what labels to draw at which values.intThis method returns the major tick spacing.Return the maximum value supported by the multislider.Return the minimum value supported by the multislider.intThis method returns the minor tick spacing.intReturn the number of thumbs on this multislider.intReturn this multislider's vertical or horizontal orientation.booleanReturn whether overlap of the thumbs is allowed.booleanTells if labels are to be painted.booleanTells if tick marks are to be painted.booleanTells if the track (area the slider slides in) is to be painted.booleanReturn whether passing of the thumbs is allowed.getSlider(int i) Return an individual slider with index i.protected JSlider[]Return the individual sliders, where slider[0] contains the formatting.booleanReturns true if the thumb (and the data value it represents) resolve to the closest tick mark next to where the user positioned the thumb.getThumbLabel(int i) Get the thumb label for thumb i.intReturn the track size highest pixel (to calculate width for horizontal slider; height for vertical slider).intReturn the track size lowest pixel (to calculate width for horizontal slider; height for vertical slider).getUI()Gets the UI object which implements the L&F for this component.Returns the name of the L&F class that renders this component.getValue(int i) Returns the slider's current value for slider[i].booleanisBusy()Return whether one of the sliders is busy (e.g., mouse-down or a drag operation).protected booleanisBusySlider(int i) Return whether slider i is busy (e.g., mouse-down or a drag operation).booleanReturn whether thumb label display on or off.booleanReturn whether the orientation of the multislider is horizontal or not.booleanReturn whether the orientation of the multislider is vertical or not.protected abstract TmapIndexToValue(int index) Translate an index to a value.protected abstract intmapValueToIndex(T value) Translate a value to an index.voidremoveChangeListener(ChangeListener listener) Removes a ChangeListener from the multislider.voidRemoves a FinalValueChangeListener from the multislider.voidReset the slider values to the initial values.protected voidsetBusy(boolean busy) Set whether one of the sliders is busy (e.g., mouse-down or a drag operation).protected voidsetBusySlider(int i) Indicate that slider i is busy (e.g., mouse-down or a drag operation).voidsetDrawThumbLabels(boolean b, int sizePx) Turn the thumb label display on or off.voidsetExtent(int extent) Sets the size of the range "covered" by the thumb for all underlying slider objects.voidprotected voidsetIndexMaximum(int maximum) Sets the slider's maximum value tomaximum.protected voidsetIndexMinimum(int minimum) Sets the slider's minimum value tominimum.protected voidsetIndexValue(int i, int n) Sets the slider's current index value ton.voidsetInverted(boolean b) Specify true to reverse the value-range shown for the slider and false to put the value range in the normal order.voidsetLabelTable(Dictionary labels) Specify what label will be drawn at any given value.voidsetMajorTickSpacing(int n) This method sets the major tick spacing.voidsetMaximum(T maximum) Set the maximum value supported by the multislider.voidsetMinimum(T minimum) Set the minimum value supported by the multislider.voidsetMinorTickSpacing(int n) This method sets the minor tick spacing.voidsetOrientation(int orientation) Set the slider's orientation to eitherSwingConstants.VERTICALorSwingConstants.HORIZONTAL.voidsetOverlap(boolean b) Set whether overlap of the thumbs is allowed, and check whether thumb values are in line with restrictions.voidsetPaintLabels(boolean b) Determines whether labels are painted on the slider.voidsetPaintTicks(boolean b) Determines whether tick marks are painted on the slider.voidsetPaintTrack(boolean b) Determines whether the track is painted on the slider.voidsetPassing(boolean b) Set whether passing of the thumbs is allowed, and check whether thumb values are in line with restrictions.voidsetSnapToTicks(boolean b) Specifying true makes the thumb (and the data value it represents) resolve to the closest tick mark next to where the user positioned the thumb.voidsetThumbLabel(int i, String label) Set the thumb label for thumb i to the given label.voidSets the UI object which implements the L&F for all underlying sliders.voidSets the slider's current value tovalue.protected intthumbPositionPx(int i) Calculate x pixel (horizontal) or y pixel (vertical) of thumb[i], relative to the panel of the JSlider.protected intCalculate the track size (width for a horizontal slider; height for a vertical slider).voidupdateUI()Resets the UI property to a value from the current look and feel for all underlying sliders.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, getBaseline, getBaselineResizeBehavior, 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, 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, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods 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, transferFocusDownCycle, validate, validateTreeMethods 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, getAccessibleContext, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle 
- 
Constructor Details
- 
AbstractMultiSlider
public AbstractMultiSlider(int minIndex, int maxIndex, boolean horizontal, int... initialIndexValues) Creates a slider with the specified orientation and the specified minimum, maximum, and initial values. The orientation can be either horizontal or vertical.- Parameters:
 minIndex- the minimum index value of the slidermaxIndex- the maximum index value of the sliderhorizontal- the orientation of the slider; true for horizontal, false for verticalinitialIndexValues- the initial index values of the thumbs of the slider- Throws:
 IllegalArgumentException- if initial values are outside the min-max range, or if the number of thumbs is 0, or when the values are not in increasing order (which is important for restricting passing and overlap)
 
 - 
 - 
Method Details
- 
getSliders
Return the individual sliders, where slider[0] contains the formatting.- Returns:
 - the individual sliders
 
 - 
getSlider
Return an individual slider with index i.- Parameters:
 i- the index for which to retrieve the slider- Returns:
 - the individual slider with index i
 
 - 
getNumberOfThumbs
public int getNumberOfThumbs()Return the number of thumbs on this multislider.- Returns:
 - the number of thumbs on this multislider
 
 - 
setBusySlider
protected void setBusySlider(int i) Indicate that slider i is busy (e.g., mouse-down or a drag operation).- Parameters:
 i- the slider number that is busy
 - 
isBusySlider
protected boolean isBusySlider(int i) Return whether slider i is busy (e.g., mouse-down or a drag operation).- Parameters:
 i- the slider number to check- Returns:
 - whether slier i is busy or not
 
 - 
getBusySlider
protected int getBusySlider()Return which slider is busy (e.g., mouse-down or a drag operation). The function returns -1 if no slider is busy.- Returns:
 - the slider number of the busy slider, or -1 if no slider is busy with an action
 
 - 
isBusy
public boolean isBusy()Return whether one of the sliders is busy (e.g., mouse-down or a drag operation). Note that the 'busy' flag is set BEFORE the mouse event (e.g., mouse released, mouse exited) is handled. This means that when 'busy' is true, no operation is taking place.- Returns:
 - whether one of the sliders is busy or not
 
 - 
setBusy
protected void setBusy(boolean busy) Set whether one of the sliders is busy (e.g., mouse-down or a drag operation). Note that the 'busy' flag has to be set BEFORE the mouse event (e.g., mouse released, mouse exited) is handled. This means that when 'busy' is true, no operation is taking place.- Parameters:
 busy- set whether one of the sliders is busy or not
 - 
resetToInitialValues
public void resetToInitialValues()Reset the slider values to the initial values. - 
getLabelPanel
Return the label panel in which thumb labels can be drawn. The labels move with the thumbs.- Returns:
 - the label panel in which thumb labels can be drawn
 
 - 
setThumbLabel
Set the thumb label for thumb i to the given label.- Parameters:
 i- the thumb numberlabel- the label to display- Throws:
 IndexOutOfBoundsException- when thumb number is out of bounds
 - 
getThumbLabel
Get the thumb label for thumb i.- Parameters:
 i- the thumb number- Returns:
 - the label to display
 - Throws:
 IndexOutOfBoundsException- when thumb number is out of bounds
 - 
setDrawThumbLabels
public void setDrawThumbLabels(boolean b, int sizePx) Turn the thumb label display on or off.- Parameters:
 b- whether the thumbs are displayed or notsizePx- the height (for a horizontal slider) or width (for a vertical slider) of the label panel in pixels
 - 
isDrawThumbLabels
public boolean isDrawThumbLabels()Return whether thumb label display on or off.- Returns:
 - whether the thumbs are displayed or not
 
 - 
calculateTrackSize
protected void calculateTrackSize()Recalculate the track size (width for horizontal slider; height for vertical slider) after a resize operation. - 
trackSize
protected int trackSize()Calculate the track size (width for a horizontal slider; height for a vertical slider).- Returns:
 - the track size (width for a horizontal slider; height for a vertical slider
 
 - 
getTrackSizeLoPx
public int getTrackSizeLoPx()Return the track size lowest pixel (to calculate width for horizontal slider; height for vertical slider).- Returns:
 - the track size lowest pixel
 
 - 
getTrackSizeHiPx
public int getTrackSizeHiPx()Return the track size highest pixel (to calculate width for horizontal slider; height for vertical slider).- Returns:
 - the track size highest pixel
 
 - 
thumbPositionPx
protected int thumbPositionPx(int i) Calculate x pixel (horizontal) or y pixel (vertical) of thumb[i], relative to the panel of the JSlider.- Parameters:
 i- the slider number- Returns:
 - the x pixel (horizontal) or y pixel (vertical) of thumb[i], relative to the panel of the JSlider
 
 - 
getDispatcherPane
Return the glass pane on top of the multislider.- Returns:
 - the glass pane on top of the multislider
 
 - 
getUI
Gets the UI object which implements the L&F for this component.- Overrides:
 getUIin classJComponent- Returns:
 - the SliderUI object that implements the Slider L&F
 
 - 
setUI
Sets the UI object which implements the L&F for all underlying sliders.- Parameters:
 ui- the SliderUI L&F object
 - 
updateUI
public void updateUI()Resets the UI property to a value from the current look and feel for all underlying sliders.- Overrides:
 updateUIin classJComponent
 - 
getUIClassID
Returns the name of the L&F class that renders this component.- Overrides:
 getUIClassIDin classJComponent- Returns:
 - the string "SliderUI"
 
 - 
addChangeListener
Adds a ChangeListener to the multislider.- Parameters:
 listener- the ChangeListener to add
 - 
removeChangeListener
Removes a ChangeListener from the multislider.- Parameters:
 listener- the ChangeListener to remove
 - 
getChangeListeners
Returns an array of all theChangeListeners added to this MultiSlider with addChangeListener().- Returns:
 - all of the 
ChangeListeners added or an empty array if no listeners have been added 
 - 
fireStateChanged
protected void fireStateChanged()Send aChangeEvent, whose source is thisMultiSlider, to allChangeListeners that have registered interest inChangeEvents. This method is called each time aChangeEventis received from the model of one of the underlying sliders.The event instance is created if necessary, and stored in
changeEvent. - 
addFinalValueChangeListener
Adds a FinalValueChangeListener to the multislider.- Parameters:
 listener- the FinalValueChangeListener to add
 - 
removeFinalValueChangeListener
Removes a FinalValueChangeListener from the multislider.- Parameters:
 listener- the FinalValueChangeListener to remove
 - 
getFinalValueChangeListeners
Returns an array of all theFinalValueChangeListeners added to this MultiSlider with addFinalValueChangeListener().- Returns:
 - all of the 
FinalValueChangeListeners added or an empty array if no listeners have been added 
 - 
fireFinalValueChanged
protected void fireFinalValueChanged()Send aChangeEvent, whose source is thisMultiSlider, to allFinalValueChangeListeners that have registered interest inChangeEvents. This method is called when a change is final, e.g., after setValue(...), setInitialValues(), mouse up, and leaving the slider window after a drag event. Note that theChangeEvents are NOT fired when a value of an underlying slider is changed directly. The regular ChangeListener does fire these changes.The event instance is created if necessary, and stored in
changeEvent. - 
mapIndexToValue
Translate an index to a value.- Parameters:
 index- the index on the slider scale to convert- Returns:
 - the corresponding value
 
 - 
mapValueToIndex
Translate a value to an index.- Parameters:
 value- the value to convert to an index- Returns:
 - the corresponding index
 - Throws:
 IllegalArgumentException- when value cannot be mapped onto an index
 - 
getValue
Returns the slider's current value for slider[i].- Parameters:
 i- the thumb to retrieve the value from- Returns:
 - the current value of slider[i]
 - Throws:
 IllegalArgumentException- when no value is present for the index
 - 
setValue
Sets the slider's current value tovalue. This method forwards the new value to the model. If the new value is different from the previous value, all change listeners are notified.- Parameters:
 i- the thumb to set the value forvalue- the new value
 - 
getIndexValue
public int getIndexValue(int i) Returns the slider's current index value for slider[i] from theBoundedRangeModel.- Parameters:
 i- the thumb to retrieve the value from- Returns:
 - the current index value of slider[i]
 
 - 
setIndexValue
protected void setIndexValue(int i, int n) Sets the slider's current index value ton. This method forwards the new value to the model.The data model (an instance of
If the new value is different from the previous value, all change listeners are notified.BoundedRangeModel) handles any mathematical issues arising from assigning faulty values. See theBoundedRangeModeldocumentation for details.- Parameters:
 i- the thumb to set the value forn- the new index value
 - 
getIndexMinimum
protected int getIndexMinimum()Returns the minimum value supported by the slider from theBoundedRangeModel.- Returns:
 - the value of the model's minimum property
 
 - 
setIndexMinimum
protected void setIndexMinimum(int minimum) Sets the slider's minimum value tominimum. This method forwards the new minimum value to the models of all underlying sliders.The data model (an instance of
If the new minimum value is different from the previous minimum value, all change listeners are notified.BoundedRangeModel) handles any mathematical issues arising from assigning faulty values. See theBoundedRangeModeldocumentation for details.- Parameters:
 minimum- the new minimum
 - 
getMinimum
Return the minimum value supported by the multislider.- Returns:
 - the minimum typed value of the multislider
 
 - 
setMinimum
Set the minimum value supported by the multislider.- Parameters:
 minimum- the new minimum typed value of the multislider
 - 
getIndexMaximum
protected int getIndexMaximum()Returns the maximum value supported by the slider from theBoundedRangeModel.- Returns:
 - the value of the model's maximum property
 
 - 
setIndexMaximum
protected void setIndexMaximum(int maximum) Sets the slider's maximum value tomaximum. This method forwards the new maximum value to the models of all underlying sliders.The data model (an instance of
If the new maximum value is different from the previous maximum value, all change listeners are notified.BoundedRangeModel) handles any mathematical issues arising from assigning faulty values. See theBoundedRangeModeldocumentation for details.- Parameters:
 maximum- the new maximum
 - 
getMaximum
Return the maximum value supported by the multislider.- Returns:
 - the maximum typed value of the multislider
 
 - 
setMaximum
Set the maximum value supported by the multislider.- Parameters:
 maximum- the new maximum typed value of the multislider
 - 
getExtent
public int getExtent()Returns the "extent" from theBoundedRangeModel. This represents the range of values "covered" by the thumb.- Returns:
 - an int representing the extent
 
 - 
setExtent
public void setExtent(int extent) Sets the size of the range "covered" by the thumb for all underlying slider objects. Most look and feel implementations will change the value by this amount if the user clicks on either side of the thumb. This method just forwards the new extent value to the model.The data model (an instance of
If the new extent value is different from the previous extent value, all change listeners are notified.BoundedRangeModel) handles any mathematical issues arising from assigning faulty values. See theBoundedRangeModeldocumentation for details.- Parameters:
 extent- the new extent
 - 
getOrientation
public int getOrientation()Return this multislider's vertical or horizontal orientation.- Returns:
 SwingConstants.VERTICALorSwingConstants.HORIZONTAL
 - 
isHorizontal
public boolean isHorizontal()Return whether the orientation of the multislider is horizontal or not.- Returns:
 - true if the orientation of the multislider is horizontal, false when not.
 
 - 
isVertical
public boolean isVertical()Return whether the orientation of the multislider is vertical or not.- Returns:
 - true if the orientation of the multislider is vertical , false when not.
 
 - 
setOrientation
public void setOrientation(int orientation) Set the slider's orientation to eitherSwingConstants.VERTICALorSwingConstants.HORIZONTAL.- Parameters:
 orientation-HORIZONTALorVERTICAL- Throws:
 IllegalArgumentException- if orientation is not one ofVERTICAL,HORIZONTAL
 - 
setFont
- Overrides:
 setFontin classJComponent
 - 
getLabelTable
Returns the dictionary of what labels to draw at which values.- Returns:
 - the 
Dictionarycontaining labels and where to draw them 
 - 
setLabelTable
Specify what label will be drawn at any given value. The key-value pairs are of this format:{ Integer value, java.swing.JComponent label }. An easy way to generate a standard table of value labels is by using thecreateStandardLabelsmethod.- Parameters:
 labels- newDictionaryof labels, ornullto remove all labels
 - 
createStandardLabels
Creates aHashtableof numerical text labels, starting at the slider minimum, and using the increment specified. For example, if you callcreateStandardLabels( 10 )and the slider minimum is zero, then labels will be created for the values 0, 10, 20, 30, and so on.For the labels to be drawn on the slider, the returned
Hashtablemust be passed intosetLabelTable, andsetPaintLabelsmust be set totrue.For further details on the makeup of the returned
Hashtable, see thesetLabelTabledocumentation.- Parameters:
 increment- distance between labels in the generated hashtable- Returns:
 - a new 
Hashtableof labels - Throws:
 IllegalArgumentException- ifincrementis less than or equal to zero
 - 
createStandardLabels
Creates aHashtableof text labels, starting at the starting point specified, and using the increment specified. For example, if you callcreateStandardLabels( 10, 2 ), then labels will be created for the index values 2, 12, 22, 32, and so on.For the labels to be drawn on the slider, the returned
Hashtablemust be passed intosetLabelTable, andsetPaintLabelsmust be set totrue.For further details on the makeup of the returned
Hashtable, see thesetLabelTabledocumentation.- Parameters:
 increment- distance between labels in the generated hashtablestartIndex- value at which the labels will begin- Returns:
 - a new 
Hashtableof labels - Throws:
 IllegalArgumentException- ifstartis out of range, or ifincrementis less than or equal to zero
 - 
format
Format a value for e.g., the labels of the slider. By default, the formatting is done withtoString(), but this can be overridden.- Parameters:
 value- the value to format- Returns:
 - a formatted string representation of the value
 
 - 
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
 
 - 
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'sComponentOrientationproperty. Normal (non-inverted) horizontal sliders with aComponentOrientationvalue ofLEFT_TO_RIGHThave their maximum on the right. Normal horizontal sliders with aComponentOrientationvalue ofRIGHT_TO_LEFThave their maximum on the left. Normal vertical sliders have their maximum on the top. These labels are reversed when the slider is inverted.By default, the value of this property is
false.- 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
 
 - 
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.In order for major ticks to be painted,
This method will also set up a label table for you. If there is not already a label table, and the major tick spacing issetPaintTicksmust be set totrue.> 0, andgetPaintLabelsreturnstrue, a standard label table will be generated (by callingcreateStandardLabels) with labels at the major tick marks. For the example above, you would get text labels: "0", "10", "20", "30", "40", "50". The label table is then set on the slider by callingsetLabelTable.- Parameters:
 n- new value for themajorTickSpacingproperty
 - 
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
 
 - 
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.In order for minor ticks to be painted,
setPaintTicksmust be set totrue.- Parameters:
 n- new value for theminorTickSpacingproperty- See Also:
 
 - 
getSnapToTicks
public boolean getSnapToTicks()Returns true if the thumb (and the data value it represents) resolve to the closest tick mark next to where the user positioned the thumb.- Returns:
 - true if the value snaps to the nearest tick mark, else false
 
 - 
setSnapToTicks
public void setSnapToTicks(boolean b) Specifying true makes the thumb (and the data value it represents) resolve to the closest tick mark next to where the user positioned the thumb. By default, this property isfalse.- Parameters:
 b- true to snap the thumb to the nearest tick mark
 - 
getPaintTicks
public boolean getPaintTicks()Tells if tick marks are to be painted.- Returns:
 - true if tick marks are painted, else false
 
 - 
setPaintTicks
public void setPaintTicks(boolean b) Determines whether tick marks are painted on the slider. By default, this property isfalse.- Parameters:
 b- whether or not tick marks should be painted
 - 
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
 
 - 
setPaintTrack
public void setPaintTrack(boolean b) Determines whether the track is painted on the slider. By default, this property istrue. It is up to the look and feel to honor this property, some may choose to ignore it.- Parameters:
 b- whether or not to paint the slider track- See Also:
 
 - 
getPaintLabels
public boolean getPaintLabels()Tells if labels are to be painted.- Returns:
 - true if labels are painted, else false
 
 - 
setPaintLabels
public void setPaintLabels(boolean b) Determines whether labels are painted on the slider.This method will also set up a label table for you. If there is not already a label table, and the major tick spacing is
By default, this property is> 0, a standard label table will be generated (by callingcreateStandardLabels) with labels at the major tick marks. The label table is then set on the slider by callingsetLabelTable.false.- Parameters:
 b- whether or not to paint labels
 - 
setPassing
public void setPassing(boolean b) Set whether passing of the thumbs is allowed, and check whether thumb values are in line with restrictions.- Parameters:
 b- whether passing of the thumbs is allowed or not
 - 
getPassing
public boolean getPassing()Return whether passing of the thumbs is allowed.- Returns:
 - whether passing of the thumbs is allowed or not
 
 - 
setOverlap
public void setOverlap(boolean b) Set whether overlap of the thumbs is allowed, and check whether thumb values are in line with restrictions.- Parameters:
 b- whether overlap of the thumbs is allowed or not
 - 
getOverlap
public boolean getOverlap()Return whether overlap of the thumbs is allowed.- Returns:
 - whether overlap of the thumbs is allowed or not
 
 - 
checkRestrictions
protected boolean checkRestrictions()Check restrictions on all thumb values and correct values where necessary.- Returns:
 - whether compliance with the restrictions is ok; false means violation
 
 - 
checkRestrictions
protected boolean checkRestrictions(int index) Check restrictions on the thumb values of thumb 'index' and correct values where necessary.- Parameters:
 index- the slider for which to check (the only one whose value should change)- Returns:
 - whether compliance with the restrictions is ok; false means violation
 
 
 -