javax.swing.plaf.metal

Class MetalSliderUI

public class MetalSliderUI extends BasicSliderUI

A UI delegate for the {@link JSlider} component.
Nested Class Summary
protected classMetalSliderUI.MetalPropertyListener
A property change handler that updates the rendered component in response to specific property change events.
Field Summary
protected static ColordarkShadowColor
The shadow color used for drawing the track rect when the slider is enabled.
protected booleanfilledSlider
A flag that controls whether or not the track is filled up to the value of the slider.
protected static ColorhighlightColor
The highlight color used for drawing the track rect when the slider is enabled.
protected static IconhorizThumbIcon
The icon used for the thumb control of horizontally oriented sliders.
protected StringSLIDER_FILL
A key to look up the filledSlider setting in the {@link UIManager}.
protected static ColorthumbColor
The thumb color (unused, because an icon is used to draw the thumb).
protected static inttickLength
The length of the major tick marks.
protected static inttrackWidth
The track width.
protected intTICK_BUFFER
The gap between the track and the tick marks.
protected static IconvertThumbIcon
The icon used for the thumb control of vertically oriented sliders.
Constructor Summary
MetalSliderUI()
Constructs a new instance.
Method Summary
protected PropertyChangeListenercreatePropertyChangeListener(JSlider slider)
Creates a property change listener for the slider.
static ComponentUIcreateUI(JComponent component)
Returns a new instance of MetalSliderUI.
protected intgetThumbOverhang()
Returns the thumb overhang.
protected DimensiongetThumbSize()
Returns the size of the thumb icon.
intgetTickLength()
Returns the length of the major tick marks.
protected intgetTrackLength()
Returns the track length.
protected intgetTrackWidth()
Returns the track width.
voidinstallUI(JComponent c)
Installs the default for this UI delegate in the supplied component.
voidpaintFocus(Graphics g)
Draws the focus rectangle for the slider.
protected voidpaintMajorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x)
Paints the major ticks for a slider with a horizontal orientation.
protected voidpaintMajorTickForVertSlider(Graphics g, Rectangle tickBounds, int y)
Paints the major ticks for a slider with a vertical orientation.
protected voidpaintMinorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x)
Paints the minor ticks for a slider with a horizontal orientation.
protected voidpaintMinorTickForVertSlider(Graphics g, Rectangle tickBounds, int y)
Paints the minor ticks for a slider with a vertical orientation.
voidpaintThumb(Graphics g)
Paints the thumb icon for the slider.
voidpaintTrack(Graphics g)
Paints the track along which the thumb control moves.
protected voidscrollDueToClickInTrack(int dir)

Field Detail

darkShadowColor

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

filledSlider

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

highlightColor

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

horizThumbIcon

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

SLIDER_FILL

protected final String SLIDER_FILL
A key to look up the filledSlider setting in the {@link UIManager}.

thumbColor

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

tickLength

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

trackWidth

protected static int trackWidth
The track width.

TICK_BUFFER

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

vertThumbIcon

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

Constructor Detail

MetalSliderUI

public MetalSliderUI()
Constructs a new instance.

Method Detail

createPropertyChangeListener

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

Parameters: slider the slider.

Returns: A new instance of {@link MetalPropertyListener}.

createUI

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

Parameters: component the component (ignored).

Returns: A new instance of MetalSliderUI.

getThumbOverhang

protected int getThumbOverhang()
Returns the thumb overhang.

Returns: The thumb overhang.

getThumbSize

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

Returns: The size of the thumb icon.

getTickLength

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

Returns: The length of the major tick marks.

getTrackLength

protected int getTrackLength()
Returns the track length.

Returns: The track length.

getTrackWidth

protected int getTrackWidth()
Returns the track width.

Returns: The track width.

installUI

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

Parameters: c the component.

paintFocus

public void paintFocus(Graphics g)
Draws the focus rectangle for the slider. The Metal look and feel indicates that the {@link 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 {@link BasicSliderUI} class to prevent a default focus highlight from being drawn).

Parameters: g the graphics device.

paintMajorTickForHorizSlider

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

Parameters: g the graphics device. tickBounds the tick bounds. x the x 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.

Parameters: g the graphics device. tickBounds the tick bounds. y the y value for the tick.

paintMinorTickForHorizSlider

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

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.

Parameters: g the graphics device. tickBounds the tick bounds. y the y value for the tick.

paintThumb

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

Parameters: g the graphics device.

paintTrack

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

Parameters: g the graphics device.

scrollDueToClickInTrack

protected void scrollDueToClickInTrack(int dir)