javax.swing.plaf.metal
Class MetalSliderUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by javax.swing.plaf.SliderUI
          extended by javax.swing.plaf.basic.BasicSliderUI
              extended by javax.swing.plaf.metal.MetalSliderUI

public class MetalSliderUI
extends BasicSliderUI

A UI delegate for the JSlider component.


Nested Class Summary
protected  class MetalSliderUI.MetalPropertyListener
          A property change handler that updates the rendered component in response to specific property change events.
 
Nested classes/interfaces inherited from class javax.swing.plaf.basic.BasicSliderUI
BasicSliderUI.ActionScroller, BasicSliderUI.ChangeHandler, BasicSliderUI.ComponentHandler, BasicSliderUI.FocusHandler, BasicSliderUI.PropertyChangeHandler, BasicSliderUI.ScrollListener, BasicSliderUI.TrackListener
 
Field Summary
protected static Color darkShadowColor
          The shadow color used for drawing the track rect when the slider is enabled.
protected  boolean filledSlider
          A flag that controls whether or not the track is filled up to the value of the slider.
protected static Color highlightColor
          The highlight color used for drawing the track rect when the slider is enabled.
protected static Icon horizThumbIcon
          The icon used for the thumb control of horizontally oriented sliders.
protected  String SLIDER_FILL
          A key to look up the filledSlider setting in the UIManager.
protected static Color thumbColor
          The thumb color (unused, because an icon is used to draw the thumb).
protected  int TICK_BUFFER
          The gap between the track and the tick marks.
protected static int tickLength
          The length of the major tick marks.
protected static int trackWidth
          The track width.
protected static Icon vertThumbIcon
          The icon used for the thumb control of vertically oriented sliders.
 
Fields inherited from class javax.swing.plaf.basic.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
 
Constructor Summary
MetalSliderUI()
          Constructs a new instance.
 
Method Summary
protected  PropertyChangeListener createPropertyChangeListener(JSlider slider)
          Creates a property change listener for the slider.
static ComponentUI createUI(JComponent component)
          Returns a new instance of MetalSliderUI.
protected  int getThumbOverhang()
          Returns the thumb overhang.
protected  Dimension getThumbSize()
          Returns the size of the thumb icon.
 int getTickLength()
          Returns the length of the major tick marks.
protected  int getTrackLength()
          Returns the track length.
protected  int getTrackWidth()
          Returns the track width.
 void installUI(JComponent c)
          Installs the default for this UI delegate in the supplied component.
 void paintFocus(Graphics g)
          Draws the focus rectangle for the slider.
protected  void paintMajorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x)
          Paints the major ticks for a slider with a horizontal orientation.
protected  void paintMajorTickForVertSlider(Graphics g, Rectangle tickBounds, int y)
          Paints the major ticks for a slider with a vertical orientation.
protected  void paintMinorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x)
          Paints the minor ticks for a slider with a horizontal orientation.
protected  void paintMinorTickForVertSlider(Graphics g, Rectangle tickBounds, int y)
          Paints the minor ticks for a slider with a vertical orientation.
 void paintThumb(Graphics g)
          Paints the thumb icon for the slider.
 void paintTrack(Graphics g)
          Paints the track along which the thumb control moves.
protected  void scrollDueToClickInTrack(int dir)
          This method is called when there has been a click in the track and the thumb needs to be scrolled on regular intervals.
 
Methods inherited from class javax.swing.plaf.basic.BasicSliderUI
calculateContentRect, calculateFocusRect, calculateGeometry, calculateLabelRect, calculateThumbLocation, calculateThumbSize, calculateTickRect, calculateTrackBuffer, calculateTrackRect, createChangeListener, createComponentListener, createFocusListener, createScrollListener, createTrackListener, drawInverted, getFocusColor, getHeightOfHighValueLabel, getHeightOfLowValueLabel, getHeightOfTallestLabel, getHighestValueLabel, getHighlightColor, getLowestValueLabel, getMaximumSize, getMinimumHorizontalSize, getMinimumSize, getMinimumVerticalSize, getPreferredHorizontalSize, getPreferredSize, getPreferredVerticalSize, getShadowColor, getWidthOfHighValueLabel, getWidthOfLowValueLabel, getWidthOfWidestLabel, installDefaults, installKeyboardActions, installListeners, isDragging, paint, paintHorizontalLabel, paintLabels, paintTicks, paintVerticalLabel, recalculateIfInsetsChanged, recalculateIfOrientationChanged, scrollByBlock, scrollByUnit, setThumbLocation, uninstallKeyboardActions, uninstallListeners, uninstallUI, valueForXPosition, valueForYPosition, xPositionForValue, yPositionForValue
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

thumbColor

protected static Color thumbColor
The thumb color (unused, because an icon is used to draw the thumb).


highlightColor

protected static Color highlightColor
The highlight color used for drawing the track rect when the slider is enabled.


darkShadowColor

protected static Color darkShadowColor
The shadow color used for drawing the track rect when the slider is enabled.


trackWidth

protected static int trackWidth
The track width.


tickLength

protected static int tickLength
The length of the major tick marks.


horizThumbIcon

protected static Icon horizThumbIcon
The icon used for the thumb control of horizontally oriented sliders.


vertThumbIcon

protected static Icon vertThumbIcon
The icon used for the thumb control of vertically oriented sliders.


TICK_BUFFER

protected final int TICK_BUFFER
The gap between the track and the tick marks.

See Also:
Constant Field Values

SLIDER_FILL

protected final String SLIDER_FILL
A key to look up the filledSlider setting in the UIManager.

See Also:
Constant Field Values

filledSlider

protected boolean filledSlider
A flag that controls whether or not the track is filled up to the value of the slider.

Constructor Detail

MetalSliderUI

public MetalSliderUI()
Constructs a new instance.

Method Detail

createUI

public static ComponentUI createUI(JComponent component)
Returns a new instance of MetalSliderUI.

Parameters:
component - the component (ignored).
Returns:
A new instance of MetalSliderUI.

installUI

public void installUI(JComponent c)
Installs the default for this UI delegate in the supplied component.

Overrides:
installUI in class BasicSliderUI
Parameters:
c - the component.
See Also:
ComponentUI.uninstallUI(javax.swing.JComponent), JComponent.setUI(javax.swing.plaf.ComponentUI), JComponent.updateUI()

createPropertyChangeListener

protected PropertyChangeListener createPropertyChangeListener(JSlider slider)
Creates a property change listener for the slider.

Overrides:
createPropertyChangeListener in class BasicSliderUI
Parameters:
slider - the slider.
Returns:
A new instance of MetalSliderUI.MetalPropertyListener.

paintThumb

public void paintThumb(Graphics g)
Paints the thumb icon for the slider.

Overrides:
paintThumb in class BasicSliderUI
Parameters:
g - the graphics device.

paintTrack

public void paintTrack(Graphics g)
Paints the track along which the thumb control moves.

Overrides:
paintTrack in class BasicSliderUI
Parameters:
g - the graphics device.

paintFocus

public void paintFocus(Graphics g)
Draws the focus rectangle for the slider. The Metal look and feel indicates that the JSlider has the focus by changing the color of the thumb control - this is handled elsewhere and so this method is empty (it overrides the method in the BasicSliderUI class to prevent a default focus highlight from being drawn).

Overrides:
paintFocus in class BasicSliderUI
Parameters:
g - the graphics device.

getThumbSize

protected Dimension getThumbSize()
Returns the size of the thumb icon.

Overrides:
getThumbSize in class BasicSliderUI
Returns:
The size of the thumb icon.

getTickLength

public int getTickLength()
Returns the length of the major tick marks.

Overrides:
getTickLength in class BasicSliderUI
Returns:
The length of the major tick marks.

getTrackWidth

protected int getTrackWidth()
Returns the track width.

Returns:
The track width.

getTrackLength

protected int getTrackLength()
Returns the track length.

Returns:
The track length.

getThumbOverhang

protected int getThumbOverhang()
Returns the thumb overhang.

Returns:
The thumb overhang.

scrollDueToClickInTrack

protected void scrollDueToClickInTrack(int dir)
Description copied from class: BasicSliderUI
This method is called when there has been a click in the track and the thumb needs to be scrolled on regular intervals. This method is only responsible for starting the timer and not for stopping it.

Overrides:
scrollDueToClickInTrack in class BasicSliderUI
Parameters:
dir - The direction to move in.

paintMinorTickForHorizSlider

protected void paintMinorTickForHorizSlider(Graphics g,
                                            Rectangle tickBounds,
                                            int x)
Paints the minor ticks for a slider with a horizontal orientation.

Overrides:
paintMinorTickForHorizSlider in class BasicSliderUI
Parameters:
g - the graphics device.
tickBounds - the tick bounds.
x - the x value for the tick.

paintMajorTickForHorizSlider

protected void paintMajorTickForHorizSlider(Graphics g,
                                            Rectangle tickBounds,
                                            int x)
Paints the major ticks for a slider with a horizontal orientation.

Overrides:
paintMajorTickForHorizSlider in class BasicSliderUI
Parameters:
g - the graphics device.
tickBounds - the tick bounds.
x - the x value for the tick.

paintMinorTickForVertSlider

protected void paintMinorTickForVertSlider(Graphics g,
                                           Rectangle tickBounds,
                                           int y)
Paints the minor ticks for a slider with a vertical orientation.

Overrides:
paintMinorTickForVertSlider in class BasicSliderUI
Parameters:
g - the graphics device.
tickBounds - the tick bounds.
y - the y value for the tick.

paintMajorTickForVertSlider

protected void paintMajorTickForVertSlider(Graphics g,
                                           Rectangle tickBounds,
                                           int y)
Paints the major ticks for a slider with a vertical orientation.

Overrides:
paintMajorTickForVertSlider in class BasicSliderUI
Parameters:
g - the graphics device.
tickBounds - the tick bounds.
y - the y value for the tick.