Class BasicSliderUI
java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.SliderUI
javax.swing.plaf.basic.BasicSliderUI
- Direct Known Subclasses:
- MetalSliderUI,- SynthSliderUI
A Basic L&F implementation of SliderUI.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionclassAs of Java 2 platform v1.3 this undocumented class is no longer used.classData model listener.classListener for resizing events.classFocus-change listener.classA property change handler.classScroll-event listener.classTrack mouse movements.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected ChangeListenerChange listenerprotected ComponentListenerComponent listenerprotected RectangleContent rectangleprotected InsetsFocus insetsprotected FocusListenerFocus listenerprotected RectangleFocus rectangleprotected InsetsInset cacheprotected RectangleLabel rectangleprotected booleanLeft-to-right cachestatic final intMaximum scrollstatic final intMinimum scrollstatic final intNegative scrollstatic final intPositive scrollprotected PropertyChangeListenerProperty change listenerprotected BasicSliderUI.ScrollListenerScroll listenerprotected TimerScroll timerprotected JSliderSliderprotected RectangleThumb rectangleprotected RectangleTick rectangleprotected intThe distance that the track is from the side of the controlprotected BasicSliderUI.TrackListenerTrack listenerprotected RectangleTrack rectangle
- 
Constructor SummaryConstructorsConstructorDescriptionDeprecated, for removal: This API element is subject to removal in a future version.This constructor was exposed erroneously and will be removed in a future release.Constructs aBasicSliderUI.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidCalculates the content rectangle.protected voidCalculates the focus rectangle.protected voidCalculates the geometry.protected voidCalculates the label rectangle.protected voidCalculates the thumb location.protected voidCalculates the thumb size rectangle.protected voidCalculates the tick rectangle.protected voidCalculates the track buffer.protected voidCalculates the track rectangle.protected ChangeListenercreateChangeListener(JSlider slider) Creates a change listener.protected ComponentListenercreateComponentListener(JSlider slider) Creates a composite listener.protected FocusListenercreateFocusListener(JSlider slider) Creates a focus listener.protected PropertyChangeListenercreatePropertyChangeListener(JSlider slider) Creates a property change listener.protected BasicSliderUI.ScrollListenercreateScrollListener(JSlider slider) Creates a scroll listener.protected BasicSliderUI.TrackListenercreateTrackListener(JSlider slider) Creates a track listener.static ComponentUICreates a UI.protected booleanDraws inverted.intgetBaseline(JComponent c, int width, int height) Returns the baseline.Returns an enum indicating how the baseline of the component changes as the size changes.protected ColorReturns the focus color.protected intReturns the height of the highest value label.protected intReturns the height of the lowest value label.protected intReturns the height of the tallest label.protected IntegerReturns the biggest value that has an entry in the label table.protected ComponentReturns the label that corresponds to the lowest slider value in the label table.protected ColorReturns the highlight color.protected IntegerReturns the smallest value that has an entry in the label table.protected ComponentReturns the label that corresponds to the highest slider value in the label table.Returns the maximum size.Returns the minimum horizontal size.Returns the minimum size.Returns the minimum vertical size.Returns the preferred horizontal size.Returns the preferred size.Returns the preferred vertical size.protected ColorReturns the shadow color.protected DimensionReturns the thumb size.protected intGets the height of the tick area for horizontal sliders and the width of the tick area for vertical sliders.protected intReturns the width of the highest value label.protected intReturns the width of the lowest value label.protected intReturns the width of the widest label.protected voidinstallDefaults(JSlider slider) Installs the defaults.protected voidinstallKeyboardActions(JSlider slider) Installs keyboard actions.protected voidinstallListeners(JSlider slider) Installs listeners.voidInstalls a UI.protected booleanReturns true if the user is dragging the slider.protected booleanReturns true if all the labels from the label table have the same baseline.voidPaints focus.protected voidpaintHorizontalLabel(Graphics g, int value, Component label) Called for every label in the label table.voidPaints the labels.protected voidpaintMajorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x) Paints major tick for horizontal slider.protected voidpaintMajorTickForVertSlider(Graphics g, Rectangle tickBounds, int y) Paints major tick for vertical slider.protected voidpaintMinorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x) Paints minor tick for horizontal slider.protected voidpaintMinorTickForVertSlider(Graphics g, Rectangle tickBounds, int y) Paints minor tick for vertical slider.voidPaints the thumb.voidPaints ticks.voidPaints track.protected voidpaintVerticalLabel(Graphics g, int value, Component label) Called for every label in the label table.protected voidRecalculates if the insets have changed.protected voidRecalculates if the orientation has changed.voidscrollByBlock(int direction) Scrolls by block.voidscrollByUnit(int direction) Scrolls by unit.protected voidscrollDueToClickInTrack(int dir) This function is called when a mousePressed was detected in the track, not in the thumb.voidsetThumbLocation(int x, int y) Sets the thumb location.protected voiduninstallDefaults(JSlider slider) Uninstalls the defaults.protected voiduninstallKeyboardActions(JSlider slider) Uninstalls keyboard actions.protected voiduninstallListeners(JSlider slider) Uninstalls listeners.voidUninstalls a UI.intvalueForXPosition(int xPos) Returns the value at the x position.intvalueForYPosition(int yPos) Returns the value at the y position.protected intxPositionForValue(int value) Returns the x position for a value.protected intyPositionForValue(int value) Returns the y position for a value.protected intyPositionForValue(int value, int trackY, int trackHeight) Returns the y location for the specified value.Methods declared in class javax.swing.plaf.ComponentUIcontains, getAccessibleChild, getAccessibleChildrenCount, paint, update
- 
Field Details- 
POSITIVE_SCROLLpublic static final int POSITIVE_SCROLLPositive scroll- See Also:
 
- 
NEGATIVE_SCROLLpublic static final int NEGATIVE_SCROLLNegative scroll- See Also:
 
- 
MIN_SCROLLpublic static final int MIN_SCROLLMinimum scroll- See Also:
 
- 
MAX_SCROLLpublic static final int MAX_SCROLLMaximum scroll- See Also:
 
- 
scrollTimerScroll timer
- 
sliderSlider
- 
focusInsetsFocus insets
- 
insetCacheInset cache
- 
leftToRightCacheprotected boolean leftToRightCacheLeft-to-right cache
- 
focusRectFocus rectangle
- 
contentRectContent rectangle
- 
labelRectLabel rectangle
- 
tickRectTick rectangle
- 
trackRectTrack rectangle
- 
thumbRectThumb rectangle
- 
trackBufferprotected int trackBufferThe distance that the track is from the side of the control
- 
trackListenerTrack listener
- 
changeListenerChange listener
- 
componentListenerComponent listener
- 
focusListenerFocus listener
- 
scrollListenerScroll listener
- 
propertyChangeListenerProperty change listener
 
- 
- 
Constructor Details- 
BasicSliderUIDeprecated, for removal: This API element is subject to removal in a future version.This constructor was exposed erroneously and will be removed in a future release. UseBasicSliderUI(JSlider)instead.Constructs aBasicSliderUI.- Since:
- 16
 
- 
BasicSliderUI
 
- 
- 
Method Details- 
getShadowColor
- 
getHighlightColor
- 
getFocusColor
- 
isDraggingprotected boolean isDragging()Returns true if the user is dragging the slider.- Returns:
- true if the user is dragging the slider
- Since:
- 1.5
 
- 
createUICreates a UI.- Parameters:
- b- a component
- Returns:
- a UI
 
- 
installUIInstalls a UI.- Overrides:
- installUIin class- ComponentUI
- Parameters:
- c- a component
- See Also:
 
- 
uninstallUIUninstalls a UI.- Overrides:
- uninstallUIin class- ComponentUI
- Parameters:
- c- a component
- See Also:
 
- 
installDefaults
- 
uninstallDefaultsUninstalls the defaults.- Parameters:
- slider- a slider
 
- 
createTrackListenerCreates a track listener.- Parameters:
- slider- a slider
- Returns:
- a track listener
 
- 
createChangeListenerCreates a change listener.- Parameters:
- slider- a slider
- Returns:
- a change listener
 
- 
createComponentListenerCreates a composite listener.- Parameters:
- slider- a slider
- Returns:
- a composite listener
 
- 
createFocusListenerCreates a focus listener.- Parameters:
- slider- a slider
- Returns:
- a focus listener
 
- 
createScrollListenerCreates a scroll listener.- Parameters:
- slider- a slider
- Returns:
- a scroll listener
 
- 
createPropertyChangeListenerCreates a property change listener.- Parameters:
- slider- a slider
- Returns:
- a property change listener
 
- 
installListeners
- 
uninstallListenersUninstalls listeners.- Parameters:
- slider- a slider
 
- 
installKeyboardActionsInstalls keyboard actions.- Parameters:
- slider- a slider
 
- 
uninstallKeyboardActionsUninstalls keyboard actions.- Parameters:
- slider- a slider
 
- 
getBaselineReturns the baseline.- Overrides:
- getBaselinein class- ComponentUI
- Parameters:
- c-- JComponentbaseline is being requested for
- width- the width to get the baseline for
- height- the height to get the baseline for
- Returns:
- baseline or a value < 0 indicating there is no reasonable baseline
- Throws:
- NullPointerException- if- cis- null
- IllegalArgumentException- if width or height is < 0
- Since:
- 1.6
- See Also:
 
- 
getBaselineResizeBehaviorReturns an enum indicating how the baseline of the component changes as the size changes.- Overrides:
- getBaselineResizeBehaviorin class- ComponentUI
- Parameters:
- c-- JComponentto return baseline resize behavior for
- Returns:
- an enum indicating how the baseline changes as the component size changes
- Throws:
- NullPointerException- if- cis- null
- Since:
- 1.6
- See Also:
 
- 
labelsHaveSameBaselinesprotected boolean labelsHaveSameBaselines()Returns true if all the labels from the label table have the same baseline.- Returns:
- true if all the labels from the label table have the same baseline
- Since:
- 1.6
 
- 
getPreferredHorizontalSizeReturns the preferred horizontal size.- Returns:
- the preferred horizontal size
 
- 
getPreferredVerticalSizeReturns the preferred vertical size.- Returns:
- the preferred vertical size
 
- 
getMinimumHorizontalSizeReturns the minimum horizontal size.- Returns:
- the minimum horizontal size
 
- 
getMinimumVerticalSizeReturns the minimum vertical size.- Returns:
- the minimum vertical size
 
- 
getPreferredSizeReturns the preferred size.- Overrides:
- getPreferredSizein class- ComponentUI
- Parameters:
- c- a component
- Returns:
- the preferred size
- See Also:
 
- 
getMinimumSizeReturns the minimum size.- Overrides:
- getMinimumSizein class- ComponentUI
- Parameters:
- c- a component
- Returns:
- the minimum size
- See Also:
 
- 
getMaximumSizeReturns the maximum size.- Overrides:
- getMaximumSizein class- ComponentUI
- Parameters:
- c- a component
- Returns:
- the maximum size
- See Also:
 
- 
calculateGeometryprotected void calculateGeometry()Calculates the geometry.
- 
calculateFocusRectprotected void calculateFocusRect()Calculates the focus rectangle.
- 
calculateThumbSizeprotected void calculateThumbSize()Calculates the thumb size rectangle.
- 
calculateContentRectprotected void calculateContentRect()Calculates the content rectangle.
- 
calculateThumbLocationprotected void calculateThumbLocation()Calculates the thumb location.
- 
calculateTrackBufferprotected void calculateTrackBuffer()Calculates the track buffer.
- 
calculateTrackRectprotected void calculateTrackRect()Calculates the track rectangle.
- 
getTickLengthprotected int getTickLength()Gets the height of the tick area for horizontal sliders and the width of the tick area for vertical sliders. BasicSliderUI uses the returned value to determine the tick area rectangle. If you want to give your ticks some room, make this larger than you need and paint your ticks away from the sides in paintTicks().- Returns:
- an integer representing the height of the tick area for horizontal sliders, and the width of the tick area for the vertical sliders
 
- 
calculateTickRectprotected void calculateTickRect()Calculates the tick rectangle.
- 
calculateLabelRectprotected void calculateLabelRect()Calculates the label rectangle.
- 
getThumbSize
- 
getWidthOfWidestLabelprotected int getWidthOfWidestLabel()Returns the width of the widest label.- Returns:
- the width of the widest label
 
- 
getHeightOfTallestLabelprotected int getHeightOfTallestLabel()Returns the height of the tallest label.- Returns:
- the height of the tallest label
 
- 
getWidthOfHighValueLabelprotected int getWidthOfHighValueLabel()Returns the width of the highest value label.- Returns:
- the width of the highest value label
 
- 
getWidthOfLowValueLabelprotected int getWidthOfLowValueLabel()Returns the width of the lowest value label.- Returns:
- the width of the lowest value label
 
- 
getHeightOfHighValueLabelprotected int getHeightOfHighValueLabel()Returns the height of the highest value label.- Returns:
- the height of the highest value label
 
- 
getHeightOfLowValueLabelprotected int getHeightOfLowValueLabel()Returns the height of the lowest value label.- Returns:
- the height of the lowest value label
 
- 
drawInvertedprotected boolean drawInverted()Draws inverted.- Returns:
- the inverted-ness
 
- 
getHighestValueReturns the biggest value that has an entry in the label table.- Returns:
- biggest value that has an entry in the label table, or null.
- Since:
- 1.6
 
- 
getLowestValueReturns the smallest value that has an entry in the label table.- Returns:
- smallest value that has an entry in the label table, or null.
- Since:
- 1.6
 
- 
getLowestValueLabelReturns the label that corresponds to the highest slider value in the label table.- Returns:
- the label that corresponds to the highest slider value in the label table
- See Also:
 
- 
getHighestValueLabelReturns the label that corresponds to the lowest slider value in the label table.- Returns:
- the label that corresponds to the lowest slider value in the label table
- See Also:
 
- 
recalculateIfInsetsChangedprotected void recalculateIfInsetsChanged()Recalculates if the insets have changed.
- 
recalculateIfOrientationChangedprotected void recalculateIfOrientationChanged()Recalculates if the orientation has changed.
- 
paintFocus
- 
paintTrack
- 
paintTicks
- 
paintMinorTickForHorizSlider
- 
paintMajorTickForHorizSlider
- 
paintMinorTickForVertSlider
- 
paintMajorTickForVertSlider
- 
paintLabels
- 
paintHorizontalLabelCalled for every label in the label table. Used to draw the labels for horizontal sliders. The graphics have been translated to labelRect.y already.- Parameters:
- g- the graphics context in which to paint
- value- the value of the slider
- label- the component label in the label table that needs to be painted
- See Also:
 
- 
paintVerticalLabelCalled for every label in the label table. Used to draw the labels for vertical sliders. The graphics have been translated to labelRect.x already.- Parameters:
- g- the graphics context in which to paint
- value- the value of the slider
- label- the component label in the label table that needs to be painted
- See Also:
 
- 
paintThumb
- 
setThumbLocationpublic void setThumbLocation(int x, int y) Sets the thumb location.- Parameters:
- x- the x coordinate
- y- the y coordinate
 
- 
scrollByBlockpublic void scrollByBlock(int direction) Scrolls by block.- Parameters:
- direction- the direction
 
- 
scrollByUnitpublic void scrollByUnit(int direction) Scrolls by unit.- Parameters:
- direction- the direction
 
- 
scrollDueToClickInTrackprotected void scrollDueToClickInTrack(int dir) This function is called when a mousePressed was detected in the track, not in the thumb. The default behavior is to scroll by block. You can override this method to stop it from scrolling or to add additional behavior.- Parameters:
- dir- the direction and number of blocks to scroll
 
- 
xPositionForValueprotected int xPositionForValue(int value) Returns the x position for a value.- Parameters:
- value- the value
- Returns:
- the x position for a value
 
- 
yPositionForValueprotected int yPositionForValue(int value) Returns the y position for a value.- Parameters:
- value- the value
- Returns:
- the y position for a value
 
- 
yPositionForValueprotected int yPositionForValue(int value, int trackY, int trackHeight) Returns the y location for the specified value. No checking is done on the arguments. In particular iftrackHeightis negative undefined results may occur.- Parameters:
- value- the slider value to get the location for
- trackY- y-origin of the track
- trackHeight- the height of the track
- Returns:
- the y location for the specified value of the slider
- Since:
- 1.6
 
- 
valueForYPositionpublic int valueForYPosition(int yPos) Returns the value at the y position. IfyPosis beyond the track at the bottom or the top, this method sets the value to either the minimum or maximum value of the slider, depending on if the slider is inverted or not.- Parameters:
- yPos- the location of the slider along the y axis
- Returns:
- the value at the y position
 
- 
valueForXPositionpublic int valueForXPosition(int xPos) Returns the value at the x position. IfxPosis beyond the track at the left or the right, this method sets the value to either the minimum or maximum value of the slider, depending on if the slider is inverted or not.- Parameters:
- xPos- the location of the slider along the x axis
- Returns:
- the value of the x position
 
 
-