This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.swing.plaf.basic
class BasicSliderUI

java.lang.Object extended by javax.swing.plaf.ComponentUI extended by javax.swing.plaf.SliderUI extended by javax.swing.plaf.basic.BasicSliderUI
Direct Known Subclasses:
MetalSliderUI

public class BasicSliderUI
extends SliderUI

A Basic L&F implementation of SliderUI.


Nested Class Summary
 class

           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

          
 class

           Scroll-event listener.
 class

           Track mouse movements.
 
Field Summary
protected ChangeListener changeListener
          
protected ComponentListener componentListener
          
protected Rectangle contentRect
          
protected Insets focusInsets
          
protected FocusListener focusListener
          
protected Rectangle focusRect
          
protected Insets insetCache
          
protected Rectangle labelRect
          
protected boolean leftToRightCache
          
static int MAX_SCROLL
          
static int MIN_SCROLL
          
static int NEGATIVE_SCROLL
          
static int POSITIVE_SCROLL
          
protected PropertyChangeListener propertyChangeListener
          
protected BasicSliderUI.ScrollListener scrollListener
          
protected Timer scrollTimer
          
protected JSlider slider
          
protected Rectangle thumbRect
          
protected Rectangle tickRect
          
protected int trackBuffer
          
protected BasicSliderUI.TrackListener trackListener
          
protected Rectangle trackRect
          
 
Constructor Summary

          
 
Method Summary
protected void

          
protected void

          
protected void

          
protected void

          
protected void

          
protected void

          
protected void

          
protected void

          
protected void

          
protected ChangeListener

          
protected ComponentListener

          
protected FocusListener

          
protected PropertyChangeListener

          
protected BasicSliderUI.ScrollListener

          
protected BasicSliderUI.TrackListener

          
static ComponentUI

          
protected boolean

          
 int
getBaseline(JComponent c, int width, int height)

          Returns the baseline.
 Component.BaselineResizeBehavior

          Returns an enum indicating how the baseline of the component changes as the size changes.
protected Color

          
protected int

          
protected int

          
protected int

          
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

          
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.
 Dimension

          Returns the specified component's maximum size appropriate for the look and feel.
 Dimension

          
 Dimension

          Returns the specified component's minimum size appropriate for the look and feel.
 Dimension

          
 Dimension

          
 Dimension

          Returns the specified component's preferred size appropriate for the look and feel.
 Dimension

          
protected Color

          
protected Dimension

          
protected int

          Gets the height of the tick area for horizontal sliders and the width of the tick area for vertical sliders.
protected int

          
protected int

          
protected int

          
protected void

          
protected void

          
protected void

          
 void

          Configures the specified component appropriate for the look and feel.
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 the specified component appropriate for the look and feel.
 void

          
protected void
paintHorizontalLabel(Graphics g, int value, Component label)

          Called for every label in the label table.
 void

          
protected void

          
protected void

          
protected void

          
protected void

          
 void

          
 void

          
 void

          
protected void
paintVerticalLabel(Graphics g, int value, Component label)

          Called for every label in the label table.
protected void

          
protected void

          
 void
scrollByBlock(int direction)

          
 void
scrollByUnit(int direction)

          
protected void

          This function is called when a mousePressed was detected in the track, not in the thumb.
 void
setThumbLocation(int x, int y)

          
protected void

          
protected void

          
 void

          Reverses configuration which was done on the specified component during installUI.
 int

          Returns a value give an x position.
 int

          Returns a value give a y position.
protected int
xPositionForValue(int value)

          
protected int
yPositionForValue(int value)

          
protected int
yPositionForValue(int value, int trackY, int trackHeight)

          Returns the y location for the specified value.
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, createUI, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, getPreferredSize, installUI, paint, uninstallUI, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

changeListener

protected ChangeListener changeListener

componentListener

protected ComponentListener componentListener

contentRect

protected Rectangle contentRect

focusInsets

protected Insets focusInsets

focusListener

protected FocusListener focusListener

focusRect

protected Rectangle focusRect

insetCache

protected Insets insetCache

labelRect

protected Rectangle labelRect

leftToRightCache

protected boolean leftToRightCache

MAX_SCROLL

public static final int MAX_SCROLL

MIN_SCROLL

public static final int MIN_SCROLL

NEGATIVE_SCROLL

public static final int NEGATIVE_SCROLL

POSITIVE_SCROLL

public static final int POSITIVE_SCROLL

propertyChangeListener

protected PropertyChangeListener propertyChangeListener

scrollListener

protected BasicSliderUI.ScrollListener scrollListener

scrollTimer

protected Timer scrollTimer

slider

protected JSlider slider

thumbRect

protected Rectangle thumbRect

tickRect

protected Rectangle tickRect

trackBuffer

protected int trackBuffer

trackListener

protected BasicSliderUI.TrackListener trackListener

trackRect

protected Rectangle trackRect
Constructor Detail

BasicSliderUI

public BasicSliderUI(JSlider b)
Parameters:
b
Method Detail

calculateContentRect

protected void calculateContentRect()

calculateFocusRect

protected void calculateFocusRect()

calculateGeometry

protected void calculateGeometry()

calculateLabelRect

protected void calculateLabelRect()

calculateThumbLocation

protected void calculateThumbLocation()

calculateThumbSize

protected void calculateThumbSize()

calculateTickRect

protected void calculateTickRect()

calculateTrackBuffer

protected void calculateTrackBuffer()

calculateTrackRect

protected void calculateTrackRect()

createChangeListener

protected ChangeListener createChangeListener(JSlider slider)
Parameters:
slider

createComponentListener

protected ComponentListener createComponentListener(JSlider slider)
Parameters:
slider

createFocusListener

protected FocusListener createFocusListener(JSlider slider)
Parameters:
slider

createPropertyChangeListener

protected PropertyChangeListener createPropertyChangeListener(JSlider slider)
Parameters:
slider

createScrollListener

protected BasicSliderUI.ScrollListener createScrollListener(JSlider slider)
Parameters:
slider

createTrackListener

protected BasicSliderUI.TrackListener createTrackListener(JSlider slider)
Parameters:
slider

createUI

public static ComponentUI createUI(JComponent b)
Parameters:
b

drawInverted

protected boolean drawInverted()

getBaseline

public int getBaseline(JComponent c,
                       int width,
                       int height)
Returns the baseline.

Overrides:
getBaseline in class ComponentUI
Parameters:
c
width
height

getBaselineResizeBehavior

public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
Returns an enum indicating how the baseline of the component changes as the size changes.

Overrides:
getBaselineResizeBehavior in class ComponentUI
Parameters:
c

getFocusColor

protected Color getFocusColor()

getHeightOfHighValueLabel

protected int getHeightOfHighValueLabel()

getHeightOfLowValueLabel

protected int getHeightOfLowValueLabel()

getHeightOfTallestLabel

protected int getHeightOfTallestLabel()

getHighestValue

protected Integer 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.

getHighestValueLabel

protected Component getHighestValueLabel()
Returns the label that corresponds to the lowest slider value in the label table.


getHighlightColor

protected Color getHighlightColor()

getLowestValue

protected Integer 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.

getLowestValueLabel

protected Component getLowestValueLabel()
Returns the label that corresponds to the highest slider value in the label table.


getMaximumSize

public Dimension getMaximumSize(JComponent c)
Overrides:
getMaximumSize in class ComponentUI
Parameters:
c

getMinimumHorizontalSize

public Dimension getMinimumHorizontalSize()

getMinimumSize

public Dimension getMinimumSize(JComponent c)
Overrides:
getMinimumSize in class ComponentUI
Parameters:
c

getMinimumVerticalSize

public Dimension getMinimumVerticalSize()

getPreferredHorizontalSize

public Dimension getPreferredHorizontalSize()

getPreferredSize

public Dimension getPreferredSize(JComponent c)
Overrides:
getPreferredSize in class ComponentUI
Parameters:
c

getPreferredVerticalSize

public Dimension getPreferredVerticalSize()

getShadowColor

protected Color getShadowColor()

getThumbSize

protected Dimension getThumbSize()

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().


getWidthOfHighValueLabel

protected int getWidthOfHighValueLabel()

getWidthOfLowValueLabel

protected int getWidthOfLowValueLabel()

getWidthOfWidestLabel

protected int getWidthOfWidestLabel()

installDefaults

protected void installDefaults(JSlider slider)
Parameters:
slider

installKeyboardActions

protected void installKeyboardActions(JSlider slider)
Parameters:
slider

installListeners

protected void installListeners(JSlider slider)
Parameters:
slider

installUI

public void installUI(JComponent c)
Overrides:
installUI in class ComponentUI
Parameters:
c

isDragging

protected boolean isDragging()
Returns true if the user is dragging the slider.

Returns:
true if the user is dragging the slider

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

paint

public void paint(Graphics g,
                  JComponent c)
Overrides:
paint in class ComponentUI
Parameters:
g
c

paintFocus

public void paintFocus(Graphics g)
Parameters:
g

paintHorizontalLabel

protected void paintHorizontalLabel(Graphics g,
                                    int value,
                                    Component label)
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
value
label

paintLabels

public void paintLabels(Graphics g)
Parameters:
g

paintMajorTickForHorizSlider

protected void paintMajorTickForHorizSlider(Graphics g,
                                            Rectangle tickBounds,
                                            int x)
Parameters:
g
tickBounds
x

paintMajorTickForVertSlider

protected void paintMajorTickForVertSlider(Graphics g,
                                           Rectangle tickBounds,
                                           int y)
Parameters:
g
tickBounds
y

paintMinorTickForHorizSlider

protected void paintMinorTickForHorizSlider(Graphics g,
                                            Rectangle tickBounds,
                                            int x)
Parameters:
g
tickBounds
x

paintMinorTickForVertSlider

protected void paintMinorTickForVertSlider(Graphics g,
                                           Rectangle tickBounds,
                                           int y)
Parameters:
g
tickBounds
y

paintThumb

public void paintThumb(Graphics g)
Parameters:
g

paintTicks

public void paintTicks(Graphics g)
Parameters:
g

paintTrack

public void paintTrack(Graphics g)
Parameters:
g

paintVerticalLabel

protected void paintVerticalLabel(Graphics g,
                                  int value,
                                  Component label)
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
value
label

recalculateIfInsetsChanged

protected void recalculateIfInsetsChanged()

recalculateIfOrientationChanged

protected void recalculateIfOrientationChanged()

scrollByBlock

public void scrollByBlock(int direction)
Parameters:
direction

scrollByUnit

public void scrollByUnit(int direction)
Parameters:
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

setThumbLocation

public void setThumbLocation(int x,
                             int y)
Parameters:
x
y

uninstallKeyboardActions

protected void uninstallKeyboardActions(JSlider slider)
Parameters:
slider

uninstallListeners

protected void uninstallListeners(JSlider slider)
Parameters:
slider

uninstallUI

public void uninstallUI(JComponent c)
Overrides:
uninstallUI in class ComponentUI
Parameters:
c

valueForXPosition

public int valueForXPosition(int xPos)
Returns a value give an x position. If xPos is past the track at the left or the right it will set the value to the min or max of the slider, depending if the slider is inverted or not.

Parameters:
xPos

valueForYPosition

public int valueForYPosition(int yPos)
Returns a value give a y position. If yPos is past the track at the top or the bottom it will set the value to the min or max of the slider, depending if the slider is inverted or not.

Parameters:
yPos

xPositionForValue

protected int xPositionForValue(int value)
Parameters:
value

yPositionForValue

protected int yPositionForValue(int value)
Parameters:
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 if trackHeight is negative undefined results may occur.

Parameters:
value - the slider value to get the location for
trackY - y-origin of the track
trackHeight - the height of the track


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.