javax.swing.plaf.metal

Class 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 String
SLIDER_FILL
A key to look up the filledSlider setting in the UIManager.
protected int
TICK_BUFFER
The gap between the track and the tick marks.
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 static Color
thumbColor
The thumb color (unused, because an icon is used to draw the thumb).
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

MAX_SCROLL, MIN_SCROLL, NEGATIVE_SCROLL, POSITIVE_SCROLL, changeListener, componentListener, contentRect, focusInsets, focusListener, focusRect, insetCache, labelRect, leftToRightCache, 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, createPropertyChangeListener, createScrollListener, createTrackListener, createUI, drawInverted, getFocusColor, getHeightOfHighValueLabel, getHeightOfLowValueLabel, getHeightOfTallestLabel, getHighestValueLabel, getHighlightColor, getLowestValueLabel, getMaximumSize, getMinimumHorizontalSize, getMinimumSize, getMinimumVerticalSize, getPreferredHorizontalSize, getPreferredSize, getPreferredVerticalSize, getShadowColor, getThumbSize, getTickLength, getWidthOfHighValueLabel, getWidthOfLowValueLabel, getWidthOfWidestLabel, installDefaults, installKeyboardActions, installListeners, installUI, isDragging, paint, paintFocus, paintHorizontalLabel, paintLabels, paintMajorTickForHorizSlider, paintMajorTickForVertSlider, paintMinorTickForHorizSlider, paintMinorTickForVertSlider, paintThumb, paintTicks, paintTrack, paintVerticalLabel, recalculateIfInsetsChanged, recalculateIfOrientationChanged, scrollByBlock, scrollByUnit, scrollDueToClickInTrack, setThumbLocation, uninstallKeyboardActions, uninstallListeners, uninstallUI, valueForXPosition, valueForYPosition, xPositionForValue, yPositionForValue

Methods inherited from class javax.swing.plaf.ComponentUI

contains, createUI, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, getPreferredSize, installUI, paint, uninstallUI, update

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

SLIDER_FILL

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

TICK_BUFFER

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

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.

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.

vertThumbIcon

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

Constructor Details

MetalSliderUI

public MetalSliderUI()
Constructs a new instance.

Method Details

createPropertyChangeListener

protected PropertyChangeListener createPropertyChangeListener(JSlider slider)
Creates a property change listener for the slider.
Overrides:
createPropertyChangeListener in interface BasicSliderUI
Parameters:
slider - the slider.
Returns:
A new instance of MetalSliderUI.MetalPropertyListener.

createUI

public static ComponentUI createUI(JComponent component)
Returns a new instance of MetalSliderUI.
Overrides:
createUI in interface BasicSliderUI
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.
Overrides:
getThumbSize in interface BasicSliderUI
Returns:
The size of the thumb icon.

getTickLength

public int getTickLength()
Returns the length of the major tick marks.
Overrides:
getTickLength in interface BasicSliderUI
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.
Overrides:
installUI in interface BasicSliderUI
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 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 interface BasicSliderUI
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.
Overrides:
paintMajorTickForHorizSlider in interface BasicSliderUI
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.
Overrides:
paintMajorTickForVertSlider in interface BasicSliderUI
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.
Overrides:
paintMinorTickForHorizSlider in interface 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 interface BasicSliderUI
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.
Overrides:
paintThumb in interface BasicSliderUI
Parameters:
g - the graphics device.

paintTrack

public void paintTrack(Graphics g)
Paints the track along which the thumb control moves.
Overrides:
paintTrack in interface BasicSliderUI
Parameters:
g - the graphics device.

scrollDueToClickInTrack

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. This method is only responsible for starting the timer and not for stopping it.
Overrides:
scrollDueToClickInTrack in interface BasicSliderUI
Parameters:
dir - The direction to move in.

MetalSliderUI.java Copyright (C) 2005, 2006, Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.