java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.SliderUI
javax.swing.plaf.basic.BasicSliderUI
- 直接已知的子类:
-
MetalSliderUI,SynthSliderUI
SliderUI的基本L&F实现。
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass从Java 2平台v1.3开始,不再使用这个未记录的类。class数据模型监听器。class调整大小事件监听器。class焦点变化监听器。class属性更改处理程序。class滚动事件监听器。class跟踪鼠标移动。 -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ChangeListener更改监听器protected ComponentListener组件监听器protected Rectangle内容矩形protected Insets焦点插图protected FocusListener焦点监听器protected Rectangle焦点矩形protected Insets插图缓存protected Rectangle标签矩形protected boolean从左到右的缓存static final int最大滚动static final int最小滚动static final int负滚动static final int正滚动protected PropertyChangeListener属性更改监听器protected BasicSliderUI.ScrollListener滚动监听器protected Timer滚动计时器protected JSlider滑块protected Rectangle拇指矩形protected Rectangle刻度矩形protected int轨道距控件边缘的距离protected BasicSliderUI.TrackListener轨道监听器protected Rectangle轨道矩形 -
Constructor Summary
ConstructorsConstructorDescription构造一个BasicSliderUI。构造一个BasicSliderUI。 -
Method Summary
Modifier and TypeMethodDescriptionprotected void计算内容矩形。protected void计算焦点矩形。protected void计算几何。protected void计算标签矩形。protected void计算拇指位置。protected void计算拇指大小矩形。protected void计算刻度矩形。protected void计算轨道缓冲区。protected void计算轨道矩形。protected ChangeListenercreateChangeListener(JSlider slider) 创建一个更改监听器。protected ComponentListenercreateComponentListener(JSlider slider) 创建一个组合监听器。protected FocusListenercreateFocusListener(JSlider slider) 创建一个焦点监听器。protected PropertyChangeListenercreatePropertyChangeListener(JSlider slider) 创建一个属性更改监听器。protected BasicSliderUI.ScrollListenercreateScrollListener(JSlider slider) 创建一个滚动监听器。protected BasicSliderUI.TrackListenercreateTrackListener(JSlider slider) 创建一个轨道监听器。static ComponentUI创建一个UI。protected boolean绘制反转。intgetBaseline(JComponent c, int width, int height) 返回基线。返回一个枚举,指示组件的基线随大小变化而变化的方式。protected Color返回焦点颜色。protected int返回最高值标签的高度。protected int返回最低值标签的高度。protected int返回最高标签的高度。protected Integer返回标签表中具有条目的最大值。protected Component返回与标签表中最低滑块值对应的标签。protected Color返回高亮颜色。protected Integer返回标签表中具有条目的最小值。protected Component返回与标签表中最高滑块值对应的标签。返回最大尺寸。返回最小水平尺寸。返回最小尺寸。返回最小垂直尺寸。返回首选水平尺寸。返回首选尺寸。返回首选垂直尺寸。protected Color返回阴影颜色。protected Dimension返回拇指大小。protected int获取水平滑块的刻度区域高度和垂直滑块的刻度区域宽度。protected int返回最高值标签的宽度。protected int返回最低值标签的宽度。protected int返回最宽标签的宽度。protected voidinstallDefaults(JSlider slider) 安装默认值。protected voidinstallKeyboardActions(JSlider slider) 安装键盘操作。protected voidinstallListeners(JSlider slider) 安装监听器。void安装UI。protected boolean如果用户正在拖动滑块,则返回true。protected boolean如果标签表中的所有标签具有相同的基线,则返回true。void绘制焦点。protected voidpaintHorizontalLabel(Graphics g, int value, Component label) 对标签表中的每个标签调用。void绘制标签。protected voidpaintMajorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x) 为水平滑块绘制主刻度。protected voidpaintMajorTickForVertSlider(Graphics g, Rectangle tickBounds, int y) 为垂直滑块绘制主刻度。protected voidpaintMinorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x) 为水平滑块绘制次要刻度。protected voidpaintMinorTickForVertSlider(Graphics g, Rectangle tickBounds, int y) 为垂直滑块绘制次要刻度。void绘制拇指。void绘制刻度。void绘制轨道。protected voidpaintVerticalLabel(Graphics g, int value, Component label) 对标签表中的每个标签调用。protected void如果插图已更改,则重新计算。protected void如果方向已更改,则重新计算。voidscrollByBlock(int direction) 按块滚动。voidscrollByUnit(int direction) 按单位滚动。protected voidscrollDueToClickInTrack(int dir) 当在轨道中检测到mousePressed时调用此函数,而不是在拇指中。voidsetThumbLocation(int x, int y) 设置拇指位置。protected voiduninstallDefaults(JSlider slider) 卸载默认值。protected voiduninstallKeyboardActions(JSlider slider) 卸载键盘操作。protected voiduninstallListeners(JSlider slider) 卸载监听器。void卸载UI。intvalueForXPosition(int xPos) 返回x位置处的值。intvalueForYPosition(int yPos) 返回y位置处的值。protected intxPositionForValue(int value) 返回值的x位置。protected intyPositionForValue(int value) 返回值的y位置。protected intyPositionForValue(int value, int trackY, int trackHeight) 返回指定值的y位置。Methods declared in class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, paint, update
-
Field Details
-
POSITIVE_SCROLL
public static final int POSITIVE_SCROLL正滚动- 参见:
-
NEGATIVE_SCROLL
public static final int NEGATIVE_SCROLL负滚动- 参见:
-
MIN_SCROLL
public static final int MIN_SCROLL最小滚动- 参见:
-
MAX_SCROLL
public static final int MAX_SCROLL最大滚动- 参见:
-
scrollTimer
滚动计时器 -
slider
滑块 -
focusInsets
焦点插图 -
insetCache
插图缓存 -
leftToRightCache
protected boolean leftToRightCache从左到右的缓存 -
focusRect
焦点矩形 -
contentRect
内容矩形 -
labelRect
标签矩形 -
tickRect
刻度矩形 -
trackRect
轨道矩形 -
thumbRect
拇指矩形 -
trackBuffer
protected int trackBuffer轨道距控件边缘的距离 -
trackListener
轨道监听器 -
changeListener
更改监听器 -
componentListener
组件监听器 -
focusListener
焦点监听器 -
scrollListener
滚动监听器 -
propertyChangeListener
属性更改监听器
-
-
Constructor Details
-
BasicSliderUI
public BasicSliderUI()构造一个BasicSliderUI。 -
BasicSliderUI
构造一个BasicSliderUI。- 参数:
-
b- 一个滑块
-
-
Method Details
-
getShadowColor
返回阴影颜色。- 返回:
- 阴影颜色
-
getHighlightColor
返回高亮颜色。- 返回:
- 高亮颜色
-
getFocusColor
返回焦点颜色。- 返回:
- 焦点颜色
-
isDragging
protected boolean isDragging()如果用户正在拖动滑块,则返回true。- 返回:
- 如果用户正在拖动滑块,则返回true
- 自1.5起
-
createUI
创建一个UI。- 参数:
-
b- 一个组件 - 返回:
- 一个UI
-
installUI
安装一个UI。- 覆盖:
-
installUI在类ComponentUI中 - 参数:
-
c- 一个组件 - 参见:
-
uninstallUI
卸载一个UI。- 覆盖:
-
uninstallUI在类ComponentUI中 - 参数:
-
c- 一个组件 - 参见:
-
installDefaults
安装默认值。- 参数:
-
slider- 一个滑块
-
uninstallDefaults
卸载默认值。- 参数:
-
slider- 一个滑块
-
createTrackListener
创建一个轨道监听器。- 参数:
-
slider- 滑块 - 返回:
- 轨迹监听器
-
createChangeListener
创建一个变化监听器。- 参数:
-
slider- 滑块 - 返回:
- 变化监听器
-
createComponentListener
创建一个组合监听器。- 参数:
-
slider- 滑块 - 返回:
- 组合监听器
-
createFocusListener
创建一个焦点监听器。- 参数:
-
slider- 滑块 - 返回:
- 焦点监听器
-
createScrollListener
创建一个滚动监听器。- 参数:
-
slider- 滑块 - 返回:
- 滚动监听器
-
createPropertyChangeListener
创建一个属性更改监听器。- 参数:
-
slider- 滑块 - 返回:
- 属性更改监听器
-
installListeners
安装监听器。- 参数:
-
slider- 滑块
-
uninstallListeners
卸载监听器。- 参数:
-
slider- 滑块
-
installKeyboardActions
安装键盘操作。- 参数:
-
slider- 滑块
-
uninstallKeyboardActions
卸载键盘操作。- 参数:
-
slider- 滑块
-
getBaseline
返回基线。- 覆盖:
-
getBaseline在类ComponentUI - 参数:
-
c- 请求基线的JComponent -
width- 获取基线的宽度 -
height- 获取基线的高度 - 返回:
- 基线或值< 0,表示没有合理的基线
- 抛出:
-
NullPointerException- 如果c为null -
IllegalArgumentException- 如果宽度或高度< 0 - 自1.6起:
- 1.6
- 参见:
-
getBaselineResizeBehavior
返回一个枚举,指示组件的基线随大小变化而变化的方式。- 覆盖:
-
getBaselineResizeBehavior在类ComponentUI - 参数:
-
c- 要返回基线调整行为的JComponent - 返回:
- 一个枚举,指示基线随组件大小变化而变化的方式
- 抛出:
-
NullPointerException- 如果c为null - 自1.6起:
- 1.6
- 参见:
-
labelsHaveSameBaselines
protected boolean labelsHaveSameBaselines()如果标签表中的所有标签具有相同的基线,则返回true。- 返回:
- 如果标签表中的所有标签具有相同的基线,则返回true
- 自1.6起:
- 1.6
-
getPreferredHorizontalSize
返回首选水平大小。- 返回:
- 首选水平大小
-
getPreferredVerticalSize
返回首选垂直大小。- 返回:
- 首选垂直大小
-
getMinimumHorizontalSize
返回最小水平大小。- 返回:
- 最小水平大小
-
getMinimumVerticalSize
返回最小垂直大小。- 返回:
- 最小垂直大小
-
getPreferredSize
返回首选大小。- 覆盖:
-
getPreferredSize在类ComponentUI - 参数:
-
c- 一个组件 - 返回:
- 首选大小
- 参见:
-
getMinimumSize
返回最小大小。- 覆盖:
-
getMinimumSize在类ComponentUI - 参数:
-
c- 一个组件 - 返回:
- 最小大小
- 参见:
-
getMaximumSize
返回最大大小。- 覆盖:
-
getMaximumSize在类ComponentUI - 参数:
-
c- 一个组件 - 返回:
- 最大大小
- 参见:
-
calculateGeometry
protected void calculateGeometry()计算几何。 -
calculateFocusRect
protected void calculateFocusRect()计算焦点矩形。 -
calculateThumbSize
protected void calculateThumbSize()计算拇指大小矩形。 -
calculateContentRect
protected void calculateContentRect()计算内容矩形。 -
calculateThumbLocation
protected void calculateThumbLocation()计算拇指位置。 -
calculateTrackBuffer
protected void calculateTrackBuffer()计算轨迹缓冲区。 -
calculateTrackRect
protected void calculateTrackRect()计算轨迹矩形。 -
getTickLength
protected int getTickLength()获取水平滑块的刻度区域高度和垂直滑块的刻度区域宽度。BasicSliderUI使用返回的值来确定刻度区域矩形。如果要为刻度留出一些空间,请使其比所需的更大,并在paintTicks()中远离边缘绘制刻度。- 返回:
- 一个整数,表示水平滑块的刻度区域高度,以及垂直滑块的刻度区域宽度
-
calculateTickRect
protected void calculateTickRect()计算刻度矩形。 -
calculateLabelRect
protected void calculateLabelRect()计算标签矩形。 -
getThumbSize
返回拇指大小。- 返回:
- 拇指大小
-
getWidthOfWidestLabel
protected int getWidthOfWidestLabel()返回最宽标签的宽度。- 返回:
- 最宽标签的宽度
-
getHeightOfTallestLabel
protected int getHeightOfTallestLabel()返回最高标签的高度。- 返回:
- 最高标签的高度
-
getWidthOfHighValueLabel
protected int getWidthOfHighValueLabel()返回最高值标签的宽度。- 返回:
- 最高值标签的宽度
-
getWidthOfLowValueLabel
protected int getWidthOfLowValueLabel()返回最低值标签的宽度。- 返回:
- 最低值标签的宽度
-
getHeightOfHighValueLabel
protected int getHeightOfHighValueLabel()返回最高值标签的高度。- 返回:
- 最高值标签的高度
-
getHeightOfLowValueLabel
protected int getHeightOfLowValueLabel()返回最低值标签的高度。- 返回:
- 最低值标签的高度
-
drawInverted
protected boolean drawInverted()绘制反转。- 返回:
- 反转性
-
getHighestValue
返回标签表中具有条目的最大值。- 返回:
- 标签表中具有条目的最大值,或null。
- 自1.6起:
- 1.6
-
getLowestValue
返回标签表中具有条目的最小值。- 返回:
- 标签表中具有条目的最小值,或null。
- 自1.6起:
- 1.6
-
getLowestValueLabel
返回与标签表中最高滑块值对应的标签。- 返回:
- 与标签表中最高滑块值对应的标签
- 参见:
-
getHighestValueLabel
返回与标签表中最低滑块值对应的标签。- 返回:
- 与标签表中最低滑块值对应的标签
- 参见:
-
recalculateIfInsetsChanged
protected void recalculateIfInsetsChanged()如果插入发生更改,则重新计算插入。 -
recalculateIfOrientationChanged
protected void recalculateIfOrientationChanged()如果方向发生更改,则重新计算方向。 -
paintFocus
绘制焦点。- 参数:
-
g- 图形
-
paintTrack
绘制轨道。- 参数:
-
g- 图形
-
paintTicks
绘制刻度。- 参数:
-
g- 图形
-
paintMinorTickForHorizSlider
绘制水平滑块的次刻度。- 参数:
-
g- 图形 -
tickBounds- 刻度边界 -
x- x坐标
-
paintMajorTickForHorizSlider
绘制水平滑块的主刻度。- 参数:
-
g- 图形 -
tickBounds- 刻度边界 -
x- x坐标
-
paintMinorTickForVertSlider
绘制垂直滑块的次刻度。- 参数:
-
g- 图形 -
tickBounds- 刻度边界 -
y- y坐标
-
paintMajorTickForVertSlider
绘制垂直滑块的主刻度。- 参数:
-
g- 图形 -
tickBounds- 刻度边界 -
y- y坐标
-
paintLabels
绘制标签。- 参数:
-
g- 图形
-
paintHorizontalLabel
为标签表中的每个标签调用。用于绘制水平滑块的标签。图形已经被转换为labelRect.y。- 参数:
-
g- 用于绘制的图形上下文 -
value- 滑块的值 -
label- 需要绘制的标签表中的组件标签 - 参见:
-
paintVerticalLabel
为标签表中的每个标签调用。用于绘制垂直滑块的标签。图形已经被转换为labelRect.x。- 参数:
-
g- 用于绘制的图形上下文 -
value- 滑块的值 -
label- 需要绘制的标签表中的组件标签 - 参见:
-
paintThumb
绘制滑块。- 参数:
-
g- 图形
-
setThumbLocation
public void setThumbLocation(int x, int y) 设置滑块位置。- 参数:
-
x- x坐标 -
y- y坐标
-
scrollByBlock
public void scrollByBlock(int direction) 按块滚动。- 参数:
-
direction- 方向
-
scrollByUnit
public void scrollByUnit(int direction) 按单位滚动。- 参数:
-
direction- 方向
-
scrollDueToClickInTrack
protected void scrollDueToClickInTrack(int dir) 当在轨道中检测到鼠标按下而不是在滑块中时调用此函数。默认行为是按块滚动。您可以重写此方法以阻止滚动或添加额外行为。- 参数:
-
dir- 滚动的方向和块数
-
xPositionForValue
protected int xPositionForValue(int value) 返回值的x位置。- 参数:
-
value- 值 - 返回:
- 值的x位置
-
yPositionForValue
protected int yPositionForValue(int value) 返回值的y位置。- 参数:
-
value- 值 - 返回:
- 值的y位置
-
yPositionForValue
protected int yPositionForValue(int value, int trackY, int trackHeight) 返回指定值的y位置。不对参数进行检查。特别是如果trackHeight为负数,则可能会出现未定义的结果。- 参数:
-
value- 要获取位置的滑块值 -
trackY- 轨道的y起点 -
trackHeight- 轨道的高度 - 返回:
- 滑块指定值的y位置
- 自:
- 1.6
-
valueForYPosition
public int valueForYPosition(int yPos) 返回y位置的值。如果yPos超出轨道的底部或顶部,此方法将将值设置为滑块的最小值或最大值,具体取决于滑块是否倒置。- 参数:
-
yPos- 沿y轴的滑块位置 - 返回:
- y位置的值
-
valueForXPosition
public int valueForXPosition(int xPos) 返回x位置的值。如果xPos超出轨道的左侧或右侧,此方法将将值设置为滑块的最小值或最大值,具体取决于滑块是否倒置。- 参数:
-
xPos- 沿x轴的滑块位置 - 返回:
- x位置的值
-