public class BasicSliderUI extends SliderUI
Modifier and Type | Class and Description |
---|---|
class |
BasicSliderUI.ActionScroller
从Java 2平台v1.3开始,这个未记录的类就不再使用了。
|
class |
BasicSliderUI.ChangeHandler
数据模型侦听器
|
class |
BasicSliderUI.ComponentHandler
调整事件大小的侦听器。
|
class |
BasicSliderUI.FocusHandler
聚焦改变听众
|
class |
BasicSliderUI.PropertyChangeHandler |
class |
BasicSliderUI.ScrollListener
滚动事件侦听器。
|
class |
BasicSliderUI.TrackListener
跟踪鼠标移动。
|
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
BasicSliderUI(JSlider b) |
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)
protected Color getShadowColor()
protected Color getHighlightColor()
protected Color getFocusColor()
protected boolean isDragging()
public static ComponentUI createUI(JComponent b)
public void installUI(JComponent c)
ComponentUI
ComponentUI
实例作为指定组件上的UI委托时,将调用此方法。
该方法应该完全配置组件的外观,包括以下内容:
LayoutManager
上安装LayoutManager。 PropertyChangeListener
上创建/安装一个PropertyChangeListener
,以便适当地检测和响应组件属性的更改。 installUI
在
ComponentUI
c
- 正在安装此UI代理的组件
ComponentUI.uninstallUI(javax.swing.JComponent)
,
JComponent.setUI(javax.swing.plaf.ComponentUI)
,
JComponent.updateUI()
public void uninstallUI(JComponent c)
ComponentUI
installUI
上完成的installUI
。
当将此UIComponent
实例作为指定组件的UI委托删除时,将调用此方法。
该方法应该撤消在installUI中执行的installUI
,注意将JComponent
实例保持在干净的状态(没有无关的侦听器,外观特定属性对象等)。
这应该包括以下内容:
uninstallUI
在
ComponentUI
c
- 删除此UI代理的组件;
这个参数经常被忽略,但如果UI对象是无状态的并且被多个组件共享,则可能会被使用
ComponentUI.installUI(javax.swing.JComponent)
,
JComponent.updateUI()
protected void installDefaults(JSlider slider)
protected void uninstallDefaults(JSlider slider)
protected BasicSliderUI.TrackListener createTrackListener(JSlider slider)
protected ChangeListener createChangeListener(JSlider slider)
protected ComponentListener createComponentListener(JSlider slider)
protected FocusListener createFocusListener(JSlider slider)
protected BasicSliderUI.ScrollListener createScrollListener(JSlider slider)
protected PropertyChangeListener createPropertyChangeListener(JSlider slider)
protected void installListeners(JSlider slider)
protected void uninstallListeners(JSlider slider)
protected void installKeyboardActions(JSlider slider)
protected void uninstallKeyboardActions(JSlider slider)
public int getBaseline(JComponent c, int width, int height)
getBaseline
在
ComponentUI
类
c
-
JComponent
正在请求基准
width
- 获取基准的宽度
height
- 获取基准的高度
NullPointerException
- 如果
c
是
null
IllegalArgumentException
- 如果宽度或高度<0
JComponent.getBaseline(int, int)
public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
getBaselineResizeBehavior
在
ComponentUI
c
-
JComponent
返回基准调整大小行为
NullPointerException
- 如果
c
是
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)
ComponentUI
null
,则首选的大小将由组件的布局管理器计算(这是安装了特定布局管理器的任何组件的首选方法)。
此方法的默认实现返回null
。
getPreferredSize
在
ComponentUI
c
- 要查询其首选大小的组件;
这个参数经常被忽略,但如果UI对象是无状态的并且被多个组件共享,则可能会被使用
JComponent.getPreferredSize()
,
LayoutManager.preferredLayoutSize(java.awt.Container)
public Dimension getMinimumSize(JComponent c)
ComponentUI
null
,则最小大小将由组件的布局管理器计算(这是安装了特定布局管理器的任何组件的首选方法)。
此方法的默认实现调用getPreferredSize
并返回该值。
getMinimumSize
在
ComponentUI
c
- 正在查询最小大小的组件;
这个参数经常被忽略,但如果UI对象是无状态的并且被多个组件共享,则可能会被使用
Dimension
对象或
null
JComponent.getMinimumSize()
,
LayoutManager.minimumLayoutSize(java.awt.Container)
,
ComponentUI.getPreferredSize(javax.swing.JComponent)
public Dimension getMaximumSize(JComponent c)
ComponentUI
null
,则最大大小将由组件的布局管理器计算(这是安装了特定布局管理器的任何组件的首选方法)。
此方法的默认实现将调用getPreferredSize
并返回该值。
getMaximumSize
在
ComponentUI
类
c
- 查询最大大小的组件;
这个参数经常被忽略,但如果UI对象是无状态的并且被多个组件共享,则可能会被使用
Dimension
对象或
null
JComponent.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()
protected Component getHighestValueLabel()
public void paint(Graphics g, JComponent c)
ComponentUI
ComponentUI.update
指定组件正在被绘制时的方法。
子类应该覆盖此方法,并使用指定的Graphics
对象来呈现Graphics
的内容。
paint
在
ComponentUI
g
- 要绘画的
Graphics
上下文
c
- 正在涂漆的部件;
这个参数经常被忽略,但如果UI对象是无状态的并且被多个组件共享,则可能会被使用
ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)
protected void recalculateIfInsetsChanged()
protected void recalculateIfOrientationChanged()
public void paintFocus(Graphics g)
public void paintTrack(Graphics g)
public void paintTicks(Graphics g)
protected void paintMinorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x)
protected void paintMajorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x)
protected void paintMinorTickForVertSlider(Graphics g, Rectangle tickBounds, int y)
protected void paintMajorTickForVertSlider(Graphics g, Rectangle tickBounds, int y)
public void paintLabels(Graphics g)
protected void paintHorizontalLabel(Graphics g, int value, Component label)
protected void paintVerticalLabel(Graphics g, int value, Component label)
public void paintThumb(Graphics g)
public void setThumbLocation(int x, int y)
public void scrollByBlock(int direction)
public void scrollByUnit(int direction)
protected void scrollDueToClickInTrack(int dir)
protected int xPositionForValue(int value)
protected int yPositionForValue(int value)
protected int yPositionForValue(int value, int trackY, int trackHeight)
trackHeight
为负,则可能会出现未定义的结果。
value
- 获取位置的滑块值
trackY
- 轨道的y起点
trackHeight
- 轨道的高度
public int valueForYPosition(int yPos)
yPos
超出了底部或顶部的轨道,则该方法将该值设置为滑块的最小值或最大值,具体取决于滑块是否反转。
public int valueForXPosition(int xPos)
xPos
超出了左侧或右侧的轨迹,则该方法将该值设置为滑块的最小值或最大值,具体取决于滑块是否反转。
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, 2014, Oracle and/or its affiliates. All rights reserved.