APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing.plaf.basic

public Class BasicSliderUI

extends SliderUI
Class Inheritance
Known Direct Subclasses
javax.swing.plaf.metal.MetalSliderUI, javax.swing.plaf.synth.SynthSliderUI, com.sun.java.swing.plaf.motif.MotifSliderUI
Imports
java.awt.Color, .Component, .Dimension, .FontMetrics, .Graphics, .IllegalComponentStateException, .Insets, .Polygon, .Rectangle, .Toolkit, java.awt.event.ActionEvent, .ActionListener, .ComponentAdapter, .ComponentEvent, .ComponentListener, .FocusEvent, .FocusListener, .MouseEvent, java.beans.PropertyChangeEvent, .PropertyChangeListener, java.util.Dictionary, .Enumeration, javax.swing.AbstractAction, .BoundedRangeModel, .Icon, .ImageIcon, .InputMap, .JComponent, .JLabel, .JSlider, .LookAndFeel, .SwingUtilities, .Timer, .UIManager, javax.swing.event.ChangeEvent, .ChangeListener, .MouseInputAdapter, javax.swing.plaf.ComponentUI, .InsetsUIResource, .SliderUI, sun.swing.DefaultLookup, .SwingUtilities2, .UIAction

A Basic L&F implementation of SliderUI.
Author
Tom Santos

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public class
BasicSliderUI.ActionScroller

As of Java 2 platform v1.3 this undocumented class is no longer used.

public class
BasicSliderUI.ChangeHandler

Data model listener.

public class
BasicSliderUI.ComponentHandler

Listener for resizing events.

public class
BasicSliderUI.FocusHandler

Focus-change listener.

private class
public class
BasicSliderUI.PropertyChangeHandler

A property change handler.

public class
BasicSliderUI.ScrollListener

Scroll-event listener.

pack-priv static class
BasicSliderUI.SharedActionScroller

A static version of the above.

public class
BasicSliderUI.TrackListener

Track mouse movements.

Field Summary

Modifier and TypeField and Description
protected ChangeListener
changeListener

Change listener

private boolean
checkedLabelBaselines

Whether or not sameLabelBaselines is up to date.

protected ComponentListener
componentListener

Component listener

protected Rectangle
contentRect

Content rectangle

private Color
protected Insets
focusInsets

Focus insets

protected FocusListener
focusListener

Focus listener

protected Rectangle
focusRect

Focus rectangle

private BasicSliderUI.Handler
private Color
protected Insets
insetCache

Inset cache

private transient boolean
protected Rectangle
labelRect

Label rectangle

private int
protected boolean
leftToRightCache

Left-to-right cache

public static final int
MAX_SCROLL

Maximum scroll

public static final int
MIN_SCROLL

Minimum scroll

public static final int
NEGATIVE_SCROLL

Negative scroll

public static final int
POSITIVE_SCROLL

Positive scroll

protected PropertyChangeListener
propertyChangeListener

Property change listener

private boolean
sameLabelBaselines

Whether or not all the entries in the labeltable have the same baseline.

protected BasicSliderUI.ScrollListener
scrollListener

Scroll listener

protected Timer
scrollTimer

Scroll timer

private Color
private static final BasicSliderUI.Actions
protected JSlider
slider

Slider

protected Rectangle
thumbRect

Thumb rectangle

protected Rectangle
tickRect

Tick rectangle

protected int
trackBuffer

The distance that the track is from the side of the control

protected BasicSliderUI.TrackListener
trackListener

Track listener

protected Rectangle
trackRect

Track rectangle

private static Rectangle

Constructor Summary

AccessConstructor and Description
public
BasicSliderUI(JSlider
a slider
b
)

Constructs a BasicSliderUI.

Method Summary

Modifier and TypeMethod and Description
protected void
calculateContentRect()

Calculates the content rectangle.

protected void
calculateFocusRect()

Calculates the focus rectangle.

protected void
calculateGeometry()

Calculates the geometry.

protected void
calculateLabelRect()

Calculates the label rectangle.

protected void
calculateThumbLocation()

Calculates the thumb location.

protected void
calculateThumbSize()

Calculates the thumb size rectangle.

protected void
calculateTickRect()

Calculates the tick rectangle.

protected void
calculateTrackBuffer()

Calculates the track buffer.

protected void
calculateTrackRect()

Calculates the track rectangle.

protected ChangeListener

Returns:

a change listener
createChangeListener
(JSlider
a slider
slider
)

Creates a change listener.

protected ComponentListener

Returns:

a composite listener
createComponentListener
(JSlider
a slider
slider
)

Creates a composite listener.

protected FocusListener

Returns:

a focus listener
createFocusListener
(JSlider
a slider
slider
)

Creates a focus listener.

protected PropertyChangeListener

Returns:

a property change listener
createPropertyChangeListener
(JSlider
a slider
slider
)

Creates a property change listener.

protected BasicSliderUI.ScrollListener

Returns:

a scroll listener
createScrollListener
(JSlider
a slider
slider
)

Creates a scroll listener.

protected BasicSliderUI.TrackListener

Returns:

a track listener
createTrackListener
(JSlider
a slider
slider
)

Creates a track listener.

public static ComponentUI

Returns:

a UI
createUI
(JComponent
a component
b
)

Hides javax.swing.plaf.ComponentUI.createUI.

Creates a UI.

protected boolean

Returns:

the inverted-ness
drawInverted
()

Draws inverted.

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

Overrides javax.swing.plaf.ComponentUI.getBaseline.

Returns the baseline.

public Component.BaselineResizeBehavior
getBaselineResizeBehavior(JComponent c)

Overrides javax.swing.plaf.ComponentUI.getBaselineResizeBehavior.

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

protected Color

Returns:

the focus color
getFocusColor
()

Returns the focus color.

private BasicSliderUI.Handler
protected int

Returns:

the height of the highest value label
getHeightOfHighValueLabel
()

Returns the height of the highest value label.

protected int

Returns:

the height of the lowest value label
getHeightOfLowValueLabel
()

Returns the height of the lowest value label.

protected int

Returns:

the height of the tallest label
getHeightOfTallestLabel
()

Returns the height of the tallest label.

protected Integer

Returns:

biggest value that has an entry in the label table, or null.
getHighestValue
()

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

Returns the label that corresponds to the lowest slider value in the label table.

protected Color

Returns:

the highlight color
getHighlightColor
()

Returns the highlight color.

pack-priv InputMap
getInputMap(int condition, JSlider slider)

protected Integer

Returns:

smallest value that has an entry in the label table, or null.
getLowestValue
()

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

Returns the label that corresponds to the highest slider value in the label table.

public Dimension

Returns:

the maximum size
getMaximumSize
(JComponent
a component
c
)

Overrides javax.swing.plaf.ComponentUI.getMaximumSize.

Returns the maximum size.

public Dimension

Returns:

the minimum horizontal size
getMinimumHorizontalSize
()

Returns the minimum horizontal size.

public Dimension

Returns:

the minimum size
getMinimumSize
(JComponent
a component
c
)

Overrides javax.swing.plaf.ComponentUI.getMinimumSize.

Returns the minimum size.

public Dimension

Returns:

the minimum vertical size
getMinimumVerticalSize
()

Returns the minimum vertical size.

public Dimension

Returns:

the preferred horizontal size
getPreferredHorizontalSize
()

Returns the preferred horizontal size.

public Dimension

Returns:

the preferred size
getPreferredSize
(JComponent
a component
c
)

Overrides javax.swing.plaf.ComponentUI.getPreferredSize.

Returns the preferred size.

public Dimension

Returns:

the preferred vertical size
getPreferredVerticalSize
()

Returns the preferred vertical size.

protected Color

Returns:

the shadow color
getShadowColor
()

Returns the shadow color.

protected Dimension

Returns:

the thumb size
getThumbSize
()

Returns the thumb size.

protected int

Returns:

an integer representing the height of the tick area for horizontal sliders, and the width of the tick area for the vertical sliders
getTickLength
()

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

private int
protected int

Returns:

the width of the highest value label
getWidthOfHighValueLabel
()

Returns the width of the highest value label.

protected int

Returns:

the width of the lowest value label
getWidthOfLowValueLabel
()

Returns the width of the lowest value label.

protected int

Returns:

the width of the widest label
getWidthOfWidestLabel
()

Returns the width of the widest label.

protected void
installDefaults(JSlider
a slider
slider
)

Installs the defaults.

protected void
installKeyboardActions(JSlider
a slider
slider
)

Installs keyboard actions.

protected void
installListeners(JSlider
a slider
slider
)

Installs listeners.

public void
installUI(JComponent
a component
c
)

Overrides javax.swing.plaf.ComponentUI.installUI.

Installs a UI.

protected boolean

Returns:

true if the user is dragging the slider
isDragging
()

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

Returns true if all the labels from the label table have the same baseline.

pack-priv static void
loadActionMap(LazyActionMap map)

Populates ComboBox's actions.

public void
paint(Graphics g, JComponent c)

Overrides javax.swing.plaf.ComponentUI.paint.

Paints the specified component appropriately for the look and feel.

public void
paintFocus(Graphics
the graphics
g
)

Paints focus.

protected void
paintHorizontalLabel(Graphics
the graphics context in which to paint
g
,
int
the value of the slider
value
,
Component
the component label in the label table that needs to be painted
label
)

Called for every label in the label table.

public void
paintLabels(Graphics
the graphics
g
)

Paints the labels.

protected void
paintMajorTickForHorizSlider(Graphics
the graphics
g
,
Rectangle
the tick bounds
tickBounds
,
int
the x coordinate
x
)

Paints major tick for horizontal slider.

protected void
paintMajorTickForVertSlider(Graphics
the graphics
g
,
Rectangle
the tick bounds
tickBounds
,
int
the y coordinate
y
)

Paints major tick for vertical slider.

protected void
paintMinorTickForHorizSlider(Graphics
the graphics
g
,
Rectangle
the tick bounds
tickBounds
,
int
the x coordinate
x
)

Paints minor tick for horizontal slider.

protected void
paintMinorTickForVertSlider(Graphics
the graphics
g
,
Rectangle
the tick bounds
tickBounds
,
int
the y coordinate
y
)

Paints minor tick for vertical slider.

public void
paintThumb(Graphics
the graphics
g
)

Paints the thumb.

public void
paintTicks(Graphics
the graphics
g
)

Paints ticks.

public void
paintTrack(Graphics
the graphics
g
)

Paints track.

protected void
paintVerticalLabel(Graphics
the graphics context in which to paint
g
,
int
the value of the slider
value
,
Component
the component label in the label table that needs to be painted
label
)

Called for every label in the label table.

protected void
recalculateIfInsetsChanged()

Recalculates if the insets have changed.

protected void
recalculateIfOrientationChanged()

Recalculates if the orientation has changed.

public void
scrollByBlock(int
the direction
direction
)

Scrolls by block.

public void
scrollByUnit(int
the direction
direction
)

Scrolls by unit.

protected void
scrollDueToClickInTrack(int
the direction and number of blocks to scroll
dir
)

This function is called when a mousePressed was detected in the track, not in the thumb.

public void
setThumbLocation(int
the x coordinate
x
,
int
the y coordinate
y
)

Sets the thumb location.

protected void
uninstallDefaults(JSlider
a slider
slider
)

Uninstalls the defaults.

protected void
uninstallKeyboardActions(JSlider
a slider
slider
)

Uninstalls keyboard actions.

protected void
uninstallListeners(JSlider
a slider
slider
)

Uninstalls listeners.

public void
uninstallUI(JComponent
a component
c
)

Overrides javax.swing.plaf.ComponentUI.uninstallUI.

Uninstalls a UI.

public int

Returns:

the value of the x position
valueForXPosition
(int
the location of the slider along the x axis
xPos
)

Returns the value at the x position.

public int

Returns:

the value at the y position
valueForYPosition
(int
the location of the slider along the y axis
yPos
)

Returns the value at the y position.

protected int

Returns:

the x position for a value
xPositionForValue
(int
the value
value
)

Returns the x position for a value.

protected int

Returns:

the y position for a value
yPositionForValue
(int
the value
value
)

Returns the y position for a value.

protected int

Returns:

the y location for the specified value of the slider
yPositionForValue
(int
the slider value to get the location for
value
,
int
y-origin of the track
trackY
,
int
the height of the track
trackHeight
)

Returns the y location for the specified value.