Class BasicSliderUI
java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.SliderUI
javax.swing.plaf.basic.BasicSliderUI
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
As of Java 2 platform v1.3 this undocumented class is no longer used.class
Data model listener.class
Listener for resizing events.class
Focus-change listener.class
A property change handler.class
Scroll-event listener.class
Track mouse movements. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ChangeListener
Change listenerprotected ComponentListener
Component listenerprotected Rectangle
Content rectangleprotected Insets
Focus insetsprotected FocusListener
Focus listenerprotected Rectangle
Focus rectangleprotected Insets
Inset cacheprotected Rectangle
Label rectangleprotected boolean
Left-to-right cachestatic final int
Maximum scrollstatic final int
Minimum scrollstatic final int
Negative scrollstatic final int
Positive scrollprotected PropertyChangeListener
Property change listenerprotected BasicSliderUI.ScrollListener
Scroll listenerprotected Timer
Scroll timerprotected JSlider
Sliderprotected Rectangle
Thumb rectangleprotected Rectangle
Tick rectangleprotected int
The distance that the track is from the side of the controlprotected BasicSliderUI.TrackListener
Track listenerprotected Rectangle
Track rectangle -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated, 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 Summary
Modifier and TypeMethodDescriptionprotected void
Calculates the content rectangle.protected void
Calculates the focus rectangle.protected void
Calculates the geometry.protected void
Calculates the label rectangle.protected void
Calculates the thumb location.protected void
Calculates the thumb size rectangle.protected void
Calculates the tick rectangle.protected void
Calculates the track buffer.protected void
Calculates the track rectangle.protected ChangeListener
createChangeListener
(JSlider slider) Creates a change listener.protected ComponentListener
createComponentListener
(JSlider slider) Creates a composite listener.protected FocusListener
createFocusListener
(JSlider slider) Creates a focus listener.protected PropertyChangeListener
createPropertyChangeListener
(JSlider slider) Creates a property change listener.protected BasicSliderUI.ScrollListener
createScrollListener
(JSlider slider) Creates a scroll listener.protected BasicSliderUI.TrackListener
createTrackListener
(JSlider slider) Creates a track listener.static ComponentUI
Creates a UI.protected boolean
Draws inverted.int
getBaseline
(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 Color
Returns the focus color.protected int
Returns the height of the highest value label.protected int
Returns the height of the lowest value label.protected int
Returns the height of the tallest label.protected Integer
Returns the biggest value that has an entry in the label table.protected Component
Returns the label that corresponds to the lowest slider value in the label table.protected Color
Returns the highlight color.protected Integer
Returns the smallest value that has an entry in the label table.protected Component
Returns 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 Color
Returns the shadow color.protected Dimension
Returns the thumb size.protected int
Gets the height of the tick area for horizontal sliders and the width of the tick area for vertical sliders.protected int
Returns the width of the highest value label.protected int
Returns the width of the lowest value label.protected int
Returns the width of the widest label.protected void
installDefaults
(JSlider slider) Installs the defaults.protected void
installKeyboardActions
(JSlider slider) Installs keyboard actions.protected void
installListeners
(JSlider slider) Installs listeners.void
Installs a UI.protected boolean
Returns true if the user is dragging the slider.protected boolean
Returns true if all the labels from the label table have the same baseline.void
Paints focus.protected void
paintHorizontalLabel
(Graphics g, int value, Component label) Called for every label in the label table.void
Paints the labels.protected void
paintMajorTickForHorizSlider
(Graphics g, Rectangle tickBounds, int x) Paints major tick for horizontal slider.protected void
paintMajorTickForVertSlider
(Graphics g, Rectangle tickBounds, int y) Paints major tick for vertical slider.protected void
paintMinorTickForHorizSlider
(Graphics g, Rectangle tickBounds, int x) Paints minor tick for horizontal slider.protected void
paintMinorTickForVertSlider
(Graphics g, Rectangle tickBounds, int y) Paints minor tick for vertical slider.void
Paints the thumb.void
Paints ticks.void
Paints track.protected void
paintVerticalLabel
(Graphics g, int value, Component label) Called for every label in the label table.protected void
Recalculates if the insets have changed.protected void
Recalculates if the orientation has changed.void
scrollByBlock
(int direction) Scrolls by block.void
scrollByUnit
(int direction) Scrolls by unit.protected void
scrollDueToClickInTrack
(int dir) This function is called when a mousePressed was detected in the track, not in the thumb.void
setThumbLocation
(int x, int y) Sets the thumb location.protected void
uninstallDefaults
(JSlider slider) Uninstalls the defaults.protected void
uninstallKeyboardActions
(JSlider slider) Uninstalls keyboard actions.protected void
uninstallListeners
(JSlider slider) Uninstalls listeners.void
Uninstalls a UI.int
valueForXPosition
(int xPos) Returns the value at the x position.int
valueForYPosition
(int yPos) Returns the value at the y position.protected int
xPositionForValue
(int value) Returns the x position for a value.protected int
yPositionForValue
(int value) Returns the y position for a value.protected int
yPositionForValue
(int value, int trackY, int trackHeight) Returns the y location for the specified value.Methods declared in class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, paint, update
-
Field Details
-
POSITIVE_SCROLL
public static final int POSITIVE_SCROLLPositive scroll- See Also:
-
NEGATIVE_SCROLL
public static final int NEGATIVE_SCROLLNegative scroll- See Also:
-
MIN_SCROLL
public static final int MIN_SCROLLMinimum scroll- See Also:
-
MAX_SCROLL
public static final int MAX_SCROLLMaximum scroll- See Also:
-
scrollTimer
Scroll timer -
slider
Slider -
focusInsets
Focus insets -
insetCache
Inset cache -
leftToRightCache
protected boolean leftToRightCacheLeft-to-right cache -
focusRect
Focus rectangle -
contentRect
Content rectangle -
labelRect
Label rectangle -
tickRect
Tick rectangle -
trackRect
Track rectangle -
thumbRect
Thumb rectangle -
trackBuffer
protected int trackBufferThe distance that the track is from the side of the control -
trackListener
Track listener -
changeListener
Change listener -
componentListener
Component listener -
focusListener
Focus listener -
scrollListener
Scroll listener -
propertyChangeListener
Property change listener
-
-
Constructor Details
-
BasicSliderUI
Deprecated, 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
. -
BasicSliderUI
-
-
Method Details
-
getShadowColor
-
getHighlightColor
-
getFocusColor
-
isDragging
protected boolean isDragging()Returns true if the user is dragging the slider.- Returns:
- true if the user is dragging the slider
- Since:
- 1.5
-
createUI
Creates a UI.- Parameters:
b
- a component- Returns:
- a UI
-
installUI
Installs a UI.- Overrides:
installUI
in classComponentUI
- Parameters:
c
- a component- See Also:
-
uninstallUI
Uninstalls a UI.- Overrides:
uninstallUI
in classComponentUI
- Parameters:
c
- a component- See Also:
-
installDefaults
-
uninstallDefaults
Uninstalls the defaults.- Parameters:
slider
- a slider
-
createTrackListener
Creates a track listener.- Parameters:
slider
- a slider- Returns:
- a track listener
-
createChangeListener
Creates a change listener.- Parameters:
slider
- a slider- Returns:
- a change listener
-
createComponentListener
Creates a composite listener.- Parameters:
slider
- a slider- Returns:
- a composite listener
-
createFocusListener
Creates a focus listener.- Parameters:
slider
- a slider- Returns:
- a focus listener
-
createScrollListener
Creates a scroll listener.- Parameters:
slider
- a slider- Returns:
- a scroll listener
-
createPropertyChangeListener
Creates a property change listener.- Parameters:
slider
- a slider- Returns:
- a property change listener
-
installListeners
-
uninstallListeners
Uninstalls listeners.- Parameters:
slider
- a slider
-
installKeyboardActions
Installs keyboard actions.- Parameters:
slider
- a slider
-
uninstallKeyboardActions
Uninstalls keyboard actions.- Parameters:
slider
- a slider
-
getBaseline
Returns the baseline.- Overrides:
getBaseline
in classComponentUI
- Parameters:
c
-JComponent
baseline is being requested forwidth
- the width to get the baseline forheight
- the height to get the baseline for- Returns:
- baseline or a value < 0 indicating there is no reasonable baseline
- Throws:
NullPointerException
- ifc
isnull
IllegalArgumentException
- if width or height is < 0- Since:
- 1.6
- See Also:
-
getBaselineResizeBehavior
Returns an enum indicating how the baseline of the component changes as the size changes.- Overrides:
getBaselineResizeBehavior
in classComponentUI
- Parameters:
c
-JComponent
to return baseline resize behavior for- Returns:
- an enum indicating how the baseline changes as the component size changes
- Throws:
NullPointerException
- ifc
isnull
- Since:
- 1.6
- See Also:
-
labelsHaveSameBaselines
protected 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
-
getPreferredHorizontalSize
Returns the preferred horizontal size.- Returns:
- the preferred horizontal size
-
getPreferredVerticalSize
Returns the preferred vertical size.- Returns:
- the preferred vertical size
-
getMinimumHorizontalSize
Returns the minimum horizontal size.- Returns:
- the minimum horizontal size
-
getMinimumVerticalSize
Returns the minimum vertical size.- Returns:
- the minimum vertical size
-
getPreferredSize
Returns the preferred size.- Overrides:
getPreferredSize
in classComponentUI
- Parameters:
c
- a component- Returns:
- the preferred size
- See Also:
-
getMinimumSize
Returns the minimum size.- Overrides:
getMinimumSize
in classComponentUI
- Parameters:
c
- a component- Returns:
- the minimum size
- See Also:
-
getMaximumSize
Returns the maximum size.- Overrides:
getMaximumSize
in classComponentUI
- Parameters:
c
- a component- Returns:
- the maximum size
- See Also:
-
calculateGeometry
protected void calculateGeometry()Calculates the geometry. -
calculateFocusRect
protected void calculateFocusRect()Calculates the focus rectangle. -
calculateThumbSize
protected void calculateThumbSize()Calculates the thumb size rectangle. -
calculateContentRect
protected void calculateContentRect()Calculates the content rectangle. -
calculateThumbLocation
protected void calculateThumbLocation()Calculates the thumb location. -
calculateTrackBuffer
protected void calculateTrackBuffer()Calculates the track buffer. -
calculateTrackRect
protected void calculateTrackRect()Calculates the track rectangle. -
getTickLength
protected 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
-
calculateTickRect
protected void calculateTickRect()Calculates the tick rectangle. -
calculateLabelRect
protected void calculateLabelRect()Calculates the label rectangle. -
getThumbSize
-
getWidthOfWidestLabel
protected int getWidthOfWidestLabel()Returns the width of the widest label.- Returns:
- the width of the widest label
-
getHeightOfTallestLabel
protected int getHeightOfTallestLabel()Returns the height of the tallest label.- Returns:
- the height of the tallest label
-
getWidthOfHighValueLabel
protected int getWidthOfHighValueLabel()Returns the width of the highest value label.- Returns:
- the width of the highest value label
-
getWidthOfLowValueLabel
protected int getWidthOfLowValueLabel()Returns the width of the lowest value label.- Returns:
- the width of the lowest value label
-
getHeightOfHighValueLabel
protected int getHeightOfHighValueLabel()Returns the height of the highest value label.- Returns:
- the height of the highest value label
-
getHeightOfLowValueLabel
protected int getHeightOfLowValueLabel()Returns the height of the lowest value label.- Returns:
- the height of the lowest value label
-
drawInverted
protected boolean drawInverted()Draws inverted.- Returns:
- the inverted-ness
-
getHighestValue
Returns 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
-
getLowestValue
Returns 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
-
getLowestValueLabel
Returns 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:
-
getHighestValueLabel
Returns 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:
-
recalculateIfInsetsChanged
protected void recalculateIfInsetsChanged()Recalculates if the insets have changed. -
recalculateIfOrientationChanged
protected void recalculateIfOrientationChanged()Recalculates if the orientation has changed. -
paintFocus
-
paintTrack
-
paintTicks
-
paintMinorTickForHorizSlider
-
paintMajorTickForHorizSlider
-
paintMinorTickForVertSlider
-
paintMajorTickForVertSlider
-
paintLabels
-
paintHorizontalLabel
Called 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 paintvalue
- the value of the sliderlabel
- the component label in the label table that needs to be painted- See Also:
-
paintVerticalLabel
Called 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 paintvalue
- the value of the sliderlabel
- the component label in the label table that needs to be painted- See Also:
-
paintThumb
-
setThumbLocation
public void setThumbLocation(int x, int y) Sets the thumb location.- Parameters:
x
- the x coordinatey
- the y coordinate
-
scrollByBlock
public void scrollByBlock(int direction) Scrolls by block.- Parameters:
direction
- the direction
-
scrollByUnit
public void scrollByUnit(int direction) Scrolls by unit.- Parameters:
direction
- the direction
-
scrollDueToClickInTrack
protected 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
-
xPositionForValue
protected int xPositionForValue(int value) Returns the x position for a value.- Parameters:
value
- the value- Returns:
- the x position for a value
-
yPositionForValue
protected int yPositionForValue(int value) Returns the y position for a value.- Parameters:
value
- the value- Returns:
- the y position for a value
-
yPositionForValue
protected 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 iftrackHeight
is negative undefined results may occur.- Parameters:
value
- the slider value to get the location fortrackY
- y-origin of the tracktrackHeight
- the height of the track- Returns:
- the y location for the specified value of the slider
- Since:
- 1.6
-
valueForYPosition
public int valueForYPosition(int yPos) Returns the value at the y position. IfyPos
is 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
-
valueForXPosition
public int valueForXPosition(int xPos) Returns the value at the x position. IfxPos
is 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
-