Class MetalSliderUI
java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.SliderUI
javax.swing.plaf.basic.BasicSliderUI
javax.swing.plaf.metal.MetalSliderUI
A Java L&F implementation of SliderUI.
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 JavaBeans
has been added to the java.beans
package.
Please see XMLEncoder
.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
PropertyListener
forJSlider.isFilled
.Nested classes/interfaces declared in class BasicSliderUI
BasicSliderUI.ActionScroller, BasicSliderUI.ChangeHandler, BasicSliderUI.ComponentHandler, BasicSliderUI.FocusHandler, BasicSliderUI.PropertyChangeHandler, BasicSliderUI.ScrollListener, BasicSliderUI.TrackListener
Modifier 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 static Color
The color of dark shadow.protected boolean
The value of the propertyJSlider.isFilled
.protected static Color
The color of highlighting.protected static Icon
A default horizontal thumbIcon
.protected final String
Property forJSlider.isFilled
.protected static Color
The color of a thumbprotected final int
The buffer of a tick.protected static int
The length of a tick.protected static int
The width of a track.protected static Icon
A default vertical thumbIcon
.Fields declared in class BasicSliderUI
changeListener, componentListener, contentRect, focusInsets, focusListener, focusRect, insetCache, labelRect, leftToRightCache, MAX_SCROLL, MIN_SCROLL, NEGATIVE_SCROLL, POSITIVE_SCROLL, propertyChangeListener, scrollListener, scrollTimer, slider, thumbRect, tickRect, trackBuffer, trackListener, trackRect
Modifier 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected PropertyChangeListener
createPropertyChangeListener
(JSlider slider) ConstructsMetalPropertyListener
.static ComponentUI
Constructs aMetalSliderUI
instance.protected int
Returns the amount that the thumb goes past the slide bar.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 longer dimension of the slide bar.protected int
Returns the shorter dimension of the track.Methods declared in class BasicSliderUI
calculateContentRect, calculateFocusRect, calculateGeometry, calculateLabelRect, calculateThumbLocation, calculateThumbSize, calculateTickRect, calculateTrackBuffer, calculateTrackRect, createChangeListener, createComponentListener, createFocusListener, createScrollListener, createTrackListener, drawInverted, getBaseline, getBaselineResizeBehavior, getFocusColor, getHeightOfHighValueLabel, getHeightOfLowValueLabel, getHeightOfTallestLabel, getHighestValue, getHighestValueLabel, getHighlightColor, getLowestValue, getLowestValueLabel, getMaximumSize, getMinimumHorizontalSize, getMinimumSize, getMinimumVerticalSize, getPreferredHorizontalSize, getPreferredSize, getPreferredVerticalSize, getShadowColor, getThumbSize, getWidthOfHighValueLabel, getWidthOfLowValueLabel, getWidthOfWidestLabel, installDefaults, installKeyboardActions, installListeners, installUI, isDragging, labelsHaveSameBaselines, paintFocus, paintHorizontalLabel, paintLabels, paintMajorTickForHorizSlider, paintMajorTickForVertSlider, paintMinorTickForHorizSlider, paintMinorTickForVertSlider, paintThumb, paintTicks, paintTrack, paintVerticalLabel, recalculateIfInsetsChanged, recalculateIfOrientationChanged, scrollByBlock, scrollByUnit, scrollDueToClickInTrack, setThumbLocation, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, uninstallUI, valueForXPosition, valueForYPosition, xPositionForValue, yPositionForValue, yPositionForValue
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 BasicSliderUI.ScrollListener
createScrollListener
(JSlider slider) Creates a scroll listener.protected BasicSliderUI.TrackListener
createTrackListener
(JSlider slider) Creates a track listener.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
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 ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, paint, update
Modifier and TypeMethodDescriptionboolean
contains
(JComponent c, int x, int y) Returnstrue
if the specified x,y location is contained within the look and feel's defined shape of the specified component.getAccessibleChild
(JComponent c, int i) Returns thei
thAccessible
child of the object.int
Returns the number of accessible children in the object.void
paint
(Graphics g, JComponent c) Paints the specified component appropriately for the look and feel.void
update
(Graphics g, JComponent c) Notifies this UI delegate that it is time to paint the specified component.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Modifier and TypeMethodDescriptionprotected Object
clone()
Creates and returns a copy of this object.boolean
Indicates whether some other object is "equal to" this one.protected void
finalize()
Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class
<?> getClass()
Returns the runtime class of thisObject
.int
hashCode()
Returns a hash code value for this object.final void
notify()
Wakes up a single thread that is waiting on this object's monitor.final void
Wakes up all threads that are waiting on this object's monitor.toString()
Returns a string representation of the object.final void
wait()
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final void
wait
(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final void
wait
(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Field Details
-
TICK_BUFFER
protected final int TICK_BUFFERThe buffer of a tick.- See Also:
-
filledSlider
protected boolean filledSliderThe value of the propertyJSlider.isFilled
. By default,false
if the property is not set,true
for Ocean theme. -
thumbColor
The color of a thumb -
highlightColor
The color of highlighting. -
darkShadowColor
The color of dark shadow. -
trackWidth
protected static int trackWidthThe width of a track. -
tickLength
protected static int tickLengthThe length of a tick. -
horizThumbIcon
A default horizontal thumbIcon
. This field might not be used. To change theIcon
used by this delegate directly set it using theSlider.horizontalThumbIcon
UIManager property. -
vertThumbIcon
A default vertical thumbIcon
. This field might not be used. To change theIcon
used by this delegate directly set it using theSlider.verticalThumbIcon
UIManager property. -
SLIDER_FILL
-
-
Constructor Details
-
MetalSliderUI
public MetalSliderUI()Constructs aMetalSliderUI
instance.
-
-
Method Details
-
createUI
Constructs aMetalSliderUI
instance.- Parameters:
c
- a component- Returns:
- a
MetalSliderUI
instance
-
createPropertyChangeListener
ConstructsMetalPropertyListener
.- Overrides:
createPropertyChangeListener
in classBasicSliderUI
- Parameters:
slider
- aJSlider
- Returns:
- the
MetalPropertyListener
-
getTickLength
public 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.- Overrides:
getTickLength
in classBasicSliderUI
- Returns:
- an integer representing the height of the tick area for horizontal sliders, and the width of the tick area for the vertical sliders
-
getTrackWidth
protected int getTrackWidth()Returns the shorter dimension of the track.- Returns:
- the shorter dimension of the track
-
getTrackLength
protected int getTrackLength()Returns the longer dimension of the slide bar. (The slide bar is only the part that runs directly under the thumb)- Returns:
- the longer dimension of the slide bar
-
getThumbOverhang
protected int getThumbOverhang()Returns the amount that the thumb goes past the slide bar.- Returns:
- the amount that the thumb goes past the slide bar
-