MetalSliderUI
, SynthSliderUI
public class BasicSliderUI extends SliderUI
Modifier and Type | Class | Description |
---|---|---|
class |
BasicSliderUI.ActionScroller |
As of Java 2 platform v1.3 this undocumented class is no longer used.
|
class |
BasicSliderUI.ChangeHandler |
Data model listener.
|
class |
BasicSliderUI.ComponentHandler |
Listener for resizing events.
|
class |
BasicSliderUI.FocusHandler |
Focus-change listener.
|
class |
BasicSliderUI.PropertyChangeHandler |
A property change handler.
|
class |
BasicSliderUI.ScrollListener |
Scroll-event listener.
|
class |
BasicSliderUI.TrackListener |
Track mouse movements.
|
Modifier and Type | Field | Description |
---|---|---|
protected ChangeListener |
changeListener |
Change listener
|
protected ComponentListener |
componentListener |
Component listener
|
protected Rectangle |
contentRect |
Content rectangle
|
protected Insets |
focusInsets |
Focus insets
|
protected FocusListener |
focusListener |
Focus listener
|
protected Rectangle |
focusRect |
Focus rectangle
|
protected Insets |
insetCache |
Inset cache
|
protected Rectangle |
labelRect |
Label rectangle
|
protected boolean |
leftToRightCache |
Left-to-right cache
|
static int |
MAX_SCROLL |
Maximum scroll
|
static int |
MIN_SCROLL |
Minimum scroll
|
static int |
NEGATIVE_SCROLL |
Negative scroll
|
static int |
POSITIVE_SCROLL |
Positive scroll
|
protected PropertyChangeListener |
propertyChangeListener |
Property chane listener
|
protected BasicSliderUI.ScrollListener |
scrollListener |
Scroll listener
|
protected Timer |
scrollTimer |
Scroll timer
|
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
|
Constructor | Description |
---|---|
BasicSliderUI(JSlider b) |
Constructs a
BasicSliderUI . |
Modifier and Type | Method | 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 |
createChangeListener(JSlider slider) |
Creates a change listener.
|
protected ComponentListener |
createComponentListener(JSlider slider) |
Creates a composite listener.
|
protected FocusListener |
createFocusListener(JSlider slider) |
Creates a focus listener.
|
protected PropertyChangeListener |
createPropertyChangeListener(JSlider slider) |
Creates a property change listener.
|
protected BasicSliderUI.ScrollListener |
createScrollListener(JSlider slider) |
Creates a scroll listener.
|
protected BasicSliderUI.TrackListener |
createTrackListener(JSlider slider) |
Creates a track listener.
|
static ComponentUI |
createUI(JComponent b) |
Creates a UI.
|
protected boolean |
drawInverted() |
Draws inverted.
|
int |
getBaseline(JComponent c,
int width,
int height) |
Returns the baseline.
|
Component.BaselineResizeBehavior |
getBaselineResizeBehavior(JComponent c) |
Returns an enum indicating how the baseline of the component
changes as the size changes.
|
protected Color |
getFocusColor() |
Returns the focus color.
|
protected int |
getHeightOfHighValueLabel() |
Returns the height of the highest value label.
|
protected int |
getHeightOfLowValueLabel() |
Returns the height of the lowest value label.
|
protected int |
getHeightOfTallestLabel() |
Returns the height of the tallest label.
|
protected Integer |
getHighestValue() |
Returns the biggest value that has an entry in the label table.
|
protected Component |
getHighestValueLabel() |
Returns the label that corresponds to the lowest slider value in the
label table.
|
protected Color |
getHighlightColor() |
Returns the highlight color.
|
protected Integer |
getLowestValue() |
Returns the smallest value that has an entry in the label table.
|
protected Component |
getLowestValueLabel() |
Returns the label that corresponds to the highest slider value in the
label table.
|
Dimension |
getMaximumSize(JComponent c) |
Returns the maximum size.
|
Dimension |
getMinimumHorizontalSize() |
Returns the minimum horizontal size.
|
Dimension |
getMinimumSize(JComponent c) |
Returns the minimum size.
|
Dimension |
getMinimumVerticalSize() |
Returns the minimum vertical size.
|
Dimension |
getPreferredHorizontalSize() |
Returns the preferred horizontal size.
|
Dimension |
getPreferredSize(JComponent c) |
Returns the preferred size.
|
Dimension |
getPreferredVerticalSize() |
Returns the preferred vertical size.
|
protected Color |
getShadowColor() |
Returns the shadow color.
|
protected Dimension |
getThumbSize() |
Returns the thumb size.
|
protected int |
getTickLength() |
Gets the height of the tick area for horizontal sliders and the width of
the tick area for vertical sliders.
|
protected int |
getWidthOfHighValueLabel() |
Returns the width of the highest value label.
|
protected int |
getWidthOfLowValueLabel() |
Returns the width of the lowest value label.
|
protected int |
getWidthOfWidestLabel() |
Returns the width of the widest label.
|
protected void |
installDefaults(JSlider slider) |
Installs the defaults.
|
protected void |
installKeyboardActions(JSlider slider) |
Installs keyboard actions.
|
protected void |
installListeners(JSlider slider) |
Installs listeners.
|
void |
installUI(JComponent c) |
Installs a UI.
|
protected boolean |
isDragging() |
Returns true if the user is dragging the slider.
|
protected boolean |
labelsHaveSameBaselines() |
Returns true if all the labels from the label table have the same
baseline.
|
void |
paint(Graphics g,
JComponent c) |
Paints the specified component appropriately for the look and feel.
|
void |
paintFocus(Graphics g) |
Paints focus.
|
protected void |
paintHorizontalLabel(Graphics g,
int value,
Component label) |
Called for every label in the label table.
|
void |
paintLabels(Graphics g) |
Paints the labels.
|
protected void |
paintMajorTickForHorizSlider(Graphics g,
Rectangle tickBounds,
int x) |
Paints major tick for horizontal slider.
|
protected void |
paintMajorTickForVertSlider(Graphics g,
Rectangle tickBounds,
int y) |
Paints major tick for vertical slider.
|
protected void |
paintMinorTickForHorizSlider(Graphics g,
Rectangle tickBounds,
int x) |
Paints minor tick for horizontal slider.
|
protected void |
paintMinorTickForVertSlider(Graphics g,
Rectangle tickBounds,
int y) |
Paints minor tick for vertical slider.
|
void |
paintThumb(Graphics g) |
Paints the thumb.
|
void |
paintTicks(Graphics g) |
Paints ticks.
|
void |
paintTrack(Graphics g) |
Paints track.
|
protected void |
paintVerticalLabel(Graphics g,
int value,
Component 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.
|
void |
scrollByBlock(int direction) |
Scrolls by block.
|
void |
scrollByUnit(int direction) |
Scrolls by unit.
|
protected void |
scrollDueToClickInTrack(int dir) |
This function is called when a mousePressed was detected in the track,
not in the thumb.
|
void |
setThumbLocation(int x,
int y) |
Sets the thumb location.
|
protected void |
uninstallDefaults(JSlider slider) |
Uninstalls the defaults.
|
protected void |
uninstallKeyboardActions(JSlider slider) |
Uninstalls keyboard actions.
|
protected void |
uninstallListeners(JSlider slider) |
Uninstalls listeners.
|
void |
uninstallUI(JComponent c) |
Uninstalls a UI.
|
int |
valueForXPosition(int xPos) |
Returns the value at the x position.
|
int |
valueForYPosition(int yPos) |
Returns the value at the y position.
|
protected int |
xPositionForValue(int value) |
Returns the x position for a value.
|
protected int |
yPositionForValue(int value) |
Returns the y position for a value.
|
protected int |
yPositionForValue(int value,
int trackY,
int trackHeight) |
Returns the y location for the specified value.
|
contains, getAccessibleChild, getAccessibleChildrenCount, update
public static final int POSITIVE_SCROLL
public static final int NEGATIVE_SCROLL
public static final int MIN_SCROLL
public static final int MAX_SCROLL
protected Timer scrollTimer
protected JSlider slider
protected Insets focusInsets
protected Insets insetCache
protected boolean leftToRightCache
protected Rectangle focusRect
protected Rectangle contentRect
protected Rectangle labelRect
protected Rectangle tickRect
protected Rectangle trackRect
protected Rectangle thumbRect
protected int trackBuffer
protected BasicSliderUI.TrackListener trackListener
protected ChangeListener changeListener
protected ComponentListener componentListener
protected FocusListener focusListener
protected BasicSliderUI.ScrollListener scrollListener
protected PropertyChangeListener propertyChangeListener
public BasicSliderUI(JSlider b)
BasicSliderUI
.b
- a sliderprotected Color getShadowColor()
protected Color getHighlightColor()
protected Color getFocusColor()
protected boolean isDragging()
public static ComponentUI createUI(JComponent b)
b
- a componentpublic void installUI(JComponent c)
installUI
in class ComponentUI
c
- a componentComponentUI.uninstallUI(javax.swing.JComponent)
,
JComponent.setUI(javax.swing.plaf.ComponentUI)
,
JComponent.updateUI()
public void uninstallUI(JComponent c)
uninstallUI
in class ComponentUI
c
- a componentComponentUI.installUI(javax.swing.JComponent)
,
JComponent.updateUI()
protected void installDefaults(JSlider slider)
slider
- a sliderprotected void uninstallDefaults(JSlider slider)
slider
- a sliderprotected BasicSliderUI.TrackListener createTrackListener(JSlider slider)
slider
- a sliderprotected ChangeListener createChangeListener(JSlider slider)
slider
- a sliderprotected ComponentListener createComponentListener(JSlider slider)
slider
- a sliderprotected FocusListener createFocusListener(JSlider slider)
slider
- a sliderprotected BasicSliderUI.ScrollListener createScrollListener(JSlider slider)
slider
- a sliderprotected PropertyChangeListener createPropertyChangeListener(JSlider slider)
slider
- a sliderprotected void installListeners(JSlider slider)
slider
- a sliderprotected void uninstallListeners(JSlider slider)
slider
- a sliderprotected void installKeyboardActions(JSlider slider)
slider
- a sliderprotected void uninstallKeyboardActions(JSlider slider)
slider
- a sliderpublic int getBaseline(JComponent c, int width, int height)
getBaseline
in class ComponentUI
c
- JComponent
baseline is being requested forwidth
- the width to get the baseline forheight
- the height to get the baseline forNullPointerException
- if c
is null
IllegalArgumentException
- if width or height is < 0JComponent.getBaseline(int, int)
public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
getBaselineResizeBehavior
in class ComponentUI
c
- JComponent
to return baseline resize behavior forNullPointerException
- if c
is null
JComponent.getBaseline(int, int)
protected boolean labelsHaveSameBaselines()
public Dimension getPreferredHorizontalSize()
public Dimension getPreferredVerticalSize()
public Dimension getMinimumHorizontalSize()
public Dimension getMinimumVerticalSize()
public Dimension getPreferredSize(JComponent c)
getPreferredSize
in class ComponentUI
c
- a componentJComponent.getPreferredSize()
,
LayoutManager.preferredLayoutSize(java.awt.Container)
public Dimension getMinimumSize(JComponent c)
getMinimumSize
in class ComponentUI
c
- a componentJComponent.getMinimumSize()
,
LayoutManager.minimumLayoutSize(java.awt.Container)
,
ComponentUI.getPreferredSize(javax.swing.JComponent)
public Dimension getMaximumSize(JComponent c)
getMaximumSize
in class ComponentUI
c
- a componentJComponent.getMaximumSize()
,
LayoutManager2.maximumLayoutSize(java.awt.Container)
protected void calculateGeometry()
protected void calculateFocusRect()
protected void calculateThumbSize()
protected void calculateContentRect()
protected void calculateThumbLocation()
protected void calculateTrackBuffer()
protected void calculateTrackRect()
protected int getTickLength()
protected void calculateTickRect()
protected void calculateLabelRect()
protected Dimension getThumbSize()
protected int getWidthOfWidestLabel()
protected int getHeightOfTallestLabel()
protected int getWidthOfHighValueLabel()
protected int getWidthOfLowValueLabel()
protected int getHeightOfHighValueLabel()
protected int getHeightOfLowValueLabel()
protected boolean drawInverted()
protected Integer getHighestValue()
protected Integer getLowestValue()
protected Component getLowestValueLabel()
JSlider.setLabelTable(java.util.Dictionary)
protected Component getHighestValueLabel()
JSlider.setLabelTable(java.util.Dictionary)
public void paint(Graphics g, JComponent c)
ComponentUI
ComponentUI.update
method when
the specified component is being painted. Subclasses should override
this method and use the specified Graphics
object to
render the content of the component.paint
in class ComponentUI
g
- the Graphics
context in which to paintc
- the component being painted;
this argument is often ignored,
but might be used if the UI object is stateless
and shared by multiple componentsComponentUI.update(java.awt.Graphics, javax.swing.JComponent)
protected void recalculateIfInsetsChanged()
protected void recalculateIfOrientationChanged()
public void paintFocus(Graphics g)
g
- the graphicspublic void paintTrack(Graphics g)
g
- the graphicspublic void paintTicks(Graphics g)
g
- the graphicsprotected void paintMinorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x)
g
- the graphicstickBounds
- the tick boundsx
- the x coordinateprotected void paintMajorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x)
g
- the graphicstickBounds
- the tick boundsx
- the x coordinateprotected void paintMinorTickForVertSlider(Graphics g, Rectangle tickBounds, int y)
g
- the graphicstickBounds
- the tick boundsy
- the y coordinateprotected void paintMajorTickForVertSlider(Graphics g, Rectangle tickBounds, int y)
g
- the graphicstickBounds
- the tick boundsy
- the y coordinatepublic void paintLabels(Graphics g)
g
- the graphicsprotected void paintHorizontalLabel(Graphics g, int value, Component label)
g
- the graphics context in which to paintvalue
- the value of the sliderlabel
- the component label in the label table that needs to be
paintedJSlider.setLabelTable(java.util.Dictionary)
protected void paintVerticalLabel(Graphics g, int value, Component label)
g
- the graphics context in which to paintvalue
- the value of the sliderlabel
- the component label in the label table that needs to be
paintedJSlider.setLabelTable(java.util.Dictionary)
public void paintThumb(Graphics g)
g
- the graphicspublic void setThumbLocation(int x, int y)
x
- the x coordinatey
- the y coordinatepublic void scrollByBlock(int direction)
direction
- the directionpublic void scrollByUnit(int direction)
direction
- the directionprotected void scrollDueToClickInTrack(int dir)
dir
- the direction and number of blocks to scrollprotected int xPositionForValue(int value)
value
- the valueprotected int yPositionForValue(int value)
value
- the valueprotected int yPositionForValue(int value, int trackY, int trackHeight)
trackHeight
is
negative undefined results may occur.value
- the slider value to get the location fortrackY
- y-origin of the tracktrackHeight
- the height of the trackpublic int valueForYPosition(int yPos)
yPos
is beyond the
track at the bottom or the top, this method sets the value to either
the minimum or maximum value of the slider, depending on if the slider
is inverted or not.yPos
- the location of the slider along the y axispublic int valueForXPosition(int xPos)
xPos
is beyond the
track at the left or the right, this method sets the value to either the
minimum or maximum value of the slider, depending on if the slider is
inverted or not.xPos
- the location of the slider along the x axis Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2017, Oracle and/or its affiliates. 500 Oracle Parkway
Redwood Shores, CA 94065 USA. All rights reserved.
DRAFT 9-internal+0-adhoc.mlchung.jdk9-jdeps