- java.lang.Object
-
- javax.swing.plaf.ComponentUI
-
- javax.swing.plaf.ScrollBarUI
-
- javax.swing.plaf.basic.BasicScrollBarUI
-
- All Implemented Interfaces:
-
LayoutManager,SwingConstants
- 已知直接子类:
-
MetalScrollBarUI,SynthScrollBarUI
public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager, SwingConstants
实现ScrollBarUI的基本外观和感觉
-
-
Nested Class Summary
Nested Classes Modifier and Type Class 描述 protected classBasicScrollBarUI.ArrowButtonListener光标键侦听器。protected classBasicScrollBarUI.ModelListener监听模式更改的监听器。classBasicScrollBarUI.PropertyChangeHandler属性更改处理程序protected classBasicScrollBarUI.ScrollListener在ScrollPane发起的滚动事件的监听器。protected classBasicScrollBarUI.TrackListener跟踪鼠标拖动。
-
Field Summary
-
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
-
-
构造方法摘要
构造方法 Constructor 描述 BasicScrollBarUI()
-
方法摘要
所有方法 静态方法 接口方法 具体的方法 Modifier and Type 方法 描述 voidaddLayoutComponent(String name, Component child)如果布局管理器使用每个组件字符串,则将组件comp添加到布局,将其与name指定的字符串相关联。protected voidconfigureScrollBarColors()配置滚动条颜色。protected BasicScrollBarUI.ArrowButtonListenercreateArrowButtonListener()创建一个箭头按钮侦听器。protected JButtoncreateDecreaseButton(int orientation)创建减少按钮。protected JButtoncreateIncreaseButton(int orientation)创建一个增加按钮。protected BasicScrollBarUI.ModelListenercreateModelListener()创建一个模型侦听器。protected PropertyChangeListenercreatePropertyChangeListener()创建属性更改侦听器。protected BasicScrollBarUI.ScrollListenercreateScrollListener()创建一个滚动侦听器。protected BasicScrollBarUI.TrackListenercreateTrackListener()创建一个轨道监听器。static ComponentUIcreateUI(JComponent c)创建UI。DimensiongetMaximumSize(JComponent c)返回指定组件的最大尺寸,适合外观和感觉。protected DimensiongetMaximumThumbSize()返回拇指的最大可接受尺寸。protected DimensiongetMinimumThumbSize()返回拇指的最小可接受尺寸。DimensiongetPreferredSize(JComponent c)垂直滚动条的首选宽度是(非null)增量/减量按钮的最大宽度和拇指的最小宽度的最大值。booleangetSupportsAbsolutePositioning()指示用户是否可以用鼠标手势(通常是鼠标中键)绝对定位拇指。protected RectanglegetThumbBounds()返回当前的大小/位置。protected RectanglegetTrackBounds()返回轨道的当前边界,即增量和减量按钮之间的空间,减去插值。protected voidinstallComponents()安装组件。protected voidinstallDefaults()安装默认值。protected voidinstallKeyboardActions()安装键盘操作。protected voidinstallListeners()安装侦听器voidinstallUI(JComponent c)安装UIbooleanisThumbRollover()如果鼠标当前在拇指上,则返回true。voidlayoutContainer(Container scrollbarContainer)放出指定的容器。protected voidlayoutHScrollbar(JScrollBar sb)垂直滚动条。protected voidlayoutVScrollbar(JScrollBar sb)垂直滚动条。DimensionminimumLayoutSize(Container scrollbarContainer)计算指定容器的最小尺寸尺寸,给定其包含的组件。voidpaint(Graphics g, JComponent c)适当地涂抹指定的组件的外观和感觉。protected voidpaintDecreaseHighlight(Graphics g)绘制减少亮点。protected voidpaintIncreaseHighlight(Graphics g)涂抹增加亮点。protected voidpaintThumb(Graphics g, JComponent c, Rectangle thumbBounds)画拇指protected voidpaintTrack(Graphics g, JComponent c, Rectangle trackBounds)画轨道。DimensionpreferredLayoutSize(Container scrollbarContainer)计算指定容器的首选大小尺寸,给定其包含的组件。voidremoveLayoutComponent(Component child)从布局中删除指定的组件。protected voidscrollByBlock(int direction)逐块滚动protected voidscrollByUnit(int direction)按单位滚动protected voidsetThumbBounds(int x, int y, int width, int height)设置拇指的边界,并强制包含旧的thumbBounds和新的thumbBounds的重绘。protected voidsetThumbRollover(boolean active)设置鼠标是否当前在拇指上。protected voiduninstallComponents()卸载组件。protected voiduninstallDefaults()卸载默认值。protected voiduninstallKeyboardActions()卸载键盘操作。protected voiduninstallListeners()卸载侦听器。voiduninstallUI(JComponent c)卸载UI。-
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMinimumSize, update
-
-
-
-
字段详细信息
-
minimumThumbSize
protected Dimension minimumThumbSize
最小拇指尺寸
-
maximumThumbSize
protected Dimension maximumThumbSize
最大拇指大小
-
thumbHighlightColor
protected Color thumbHighlightColor
拇指高亮颜色
-
thumbLightShadowColor
protected Color thumbLightShadowColor
拇指光阴影色
-
thumbDarkShadowColor
protected Color thumbDarkShadowColor
拇指暗影色
-
thumbColor
protected Color thumbColor
拇指颜色
-
trackColor
protected Color trackColor
跟踪颜色
-
trackHighlightColor
protected Color trackHighlightColor
跟踪高亮颜色
-
scrollbar
protected JScrollBar scrollbar
滚动条
-
incrButton
protected JButton incrButton
增量按钮
-
decrButton
protected JButton decrButton
递减按钮
-
isDragging
protected boolean isDragging
拖延
-
trackListener
protected BasicScrollBarUI.TrackListener trackListener
跟踪听众
-
buttonListener
protected BasicScrollBarUI.ArrowButtonListener buttonListener
按钮监听器
-
modelListener
protected BasicScrollBarUI.ModelListener modelListener
模特儿听众
-
thumbRect
protected Rectangle thumbRect
拇指矩形
-
trackRect
protected Rectangle trackRect
跟踪矩形
-
trackHighlight
protected int trackHighlight
追踪亮点
-
NO_HIGHLIGHT
protected static final int NO_HIGHLIGHT
没有高光- 另请参见:
- Constant Field Values
-
DECREASE_HIGHLIGHT
protected static final int DECREASE_HIGHLIGHT
降低亮点- 另请参见:
- Constant Field Values
-
INCREASE_HIGHLIGHT
protected static final int INCREASE_HIGHLIGHT
增加亮点- 另请参见:
- Constant Field Values
-
scrollListener
protected BasicScrollBarUI.ScrollListener scrollListener
滚动侦听器
-
propertyChangeListener
protected PropertyChangeListener propertyChangeListener
属性更改侦听器
-
scrollTimer
protected Timer scrollTimer
滚动定时器
-
scrollBarWidth
protected int scrollBarWidth
提示什么宽度(垂直)或高度(水平时)应该是什么。- 从以下版本开始:
- 1.7
-
incrGap
protected int incrGap
增量按钮和轨道之间的距离。 这可能是负数。 如果为负,则将发生按钮和轨道之间的重叠,这对于成形按钮是有用的。- 从以下版本开始:
- 1.7
-
decrGap
protected int decrGap
减量按钮和轨道之间的距离。 这可能是负数。 如果为负,则将发生按钮和轨道之间的重叠,这对于成形按钮是有用的。- 从以下版本开始:
- 1.7
-
-
方法详细信息
-
createUI
public static ComponentUI createUI(JComponent c)
创建UI。- 参数
-
c- 组件 - 结果
- UI
-
configureScrollBarColors
protected void configureScrollBarColors()
配置滚动条颜色。
-
installUI
public void installUI(JComponent c)
安装UI
-
uninstallUI
public void uninstallUI(JComponent c)
卸载UI。- 重写:
-
uninstallUI在ComponentUI - 参数
-
c- 组件 - 另请参见:
-
ComponentUI.installUI(javax.swing.JComponent),JComponent.updateUI()
-
installDefaults
protected void installDefaults()
安装默认值。
-
installComponents
protected void installComponents()
安装组件。
-
uninstallComponents
protected void uninstallComponents()
卸载组件。
-
installListeners
protected void installListeners()
安装侦听器
-
installKeyboardActions
protected void installKeyboardActions()
安装键盘操作。
-
uninstallKeyboardActions
protected void uninstallKeyboardActions()
卸载键盘操作。
-
uninstallListeners
protected void uninstallListeners()
卸载侦听器。
-
uninstallDefaults
protected void uninstallDefaults()
卸载默认值。
-
createTrackListener
protected BasicScrollBarUI.TrackListener createTrackListener()
创建一个轨道监听器。- 结果
- 轨道听众
-
createArrowButtonListener
protected BasicScrollBarUI.ArrowButtonListener createArrowButtonListener()
创建一个箭头按钮侦听器。- 结果
- 一个箭头按钮监听器
-
createModelListener
protected BasicScrollBarUI.ModelListener createModelListener()
创建一个模型侦听器。- 结果
- 一个模特儿听众
-
createScrollListener
protected BasicScrollBarUI.ScrollListener createScrollListener()
创建一个滚动侦听器。- 结果
- 滚动侦听器
-
createPropertyChangeListener
protected PropertyChangeListener createPropertyChangeListener()
创建属性更改侦听器。- 结果
- 属性更改侦听器
-
setThumbRollover
protected void setThumbRollover(boolean active)
设置鼠标是否当前在拇指上。- 参数
-
active- True表示缩略图当前处于活动状态。 - 从以下版本开始:
- 1.5
-
isThumbRollover
public boolean isThumbRollover()
如果鼠标当前在拇指上,则返回true。- 结果
- 如果拇指当前处于活动状态,则为true
- 从以下版本开始:
- 1.5
-
paint
public void paint(Graphics g, JComponent c)
描述从类复制:ComponentUI适当地涂抹指定的组件的外观和感觉。 当指定的组件正在绘制时,将从ComponentUI.update方法调用此方法。 子类应该覆盖此方法,并使用指定的Graphics对象来呈现组件的内容。- 重写:
-
paint在ComponentUI - 参数
-
g- 要绘画的Graphics上下文 -
c- 正在涂漆的部件; 这个参数经常被忽略,但如果UI对象是无状态的并且被多个组件共享,则可能会被使用 - 另请参见:
-
ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)
-
getPreferredSize
public Dimension getPreferredSize(JComponent c)
垂直滚动条的首选宽度是(非null)增量/减量按钮的最大宽度以及拇指的最小宽度。 优选的高度是相同部件的优选高度的总和。 水平滚动条的首选尺寸的基础是相似的。preferredSize只计算一次,对此方法的后续调用只返回缓存的大小。- 重写:
-
getPreferredSize在ComponentUI - 参数
-
c- 将这种方法委托给我们的JScrollBar - 结果
- 基本JScrollBar的首选大小
- 另请参见:
-
getMaximumSize(javax.swing.JComponent),ComponentUI.getMinimumSize(javax.swing.JComponent)
-
getMaximumSize
public Dimension getMaximumSize(JComponent c)
描述从类复制:ComponentUI返回指定组件的最大尺寸,适合外观和感觉。 如果返回null,则最大大小将由组件的布局管理器计算(这是安装了特定布局管理器的任何组件的首选方法)。 此方法的默认实现将调用getPreferredSize并返回该值。- 重写:
-
getMaximumSize中的ComponentUI - 参数
-
c- 将此方法委托给我们的JScrollBar。 - 结果
- 新维度(Integer.MAX_VALUE,Integer.MAX_VALUE);
- 另请参见:
-
ComponentUI.getMinimumSize(javax.swing.JComponent),getPreferredSize(javax.swing.JComponent)
-
createDecreaseButton
protected JButton createDecreaseButton(int orientation)
创建减少按钮。- 参数
-
orientation- 方向 - 结果
- 减少按钮
-
createIncreaseButton
protected JButton createIncreaseButton(int orientation)
创建一个增加按钮。- 参数
-
orientation- 方向 - 结果
- 增加按钮
-
paintDecreaseHighlight
protected void paintDecreaseHighlight(Graphics g)
绘制减少亮点。- 参数
-
g- 图形
-
paintIncreaseHighlight
protected void paintIncreaseHighlight(Graphics g)
涂抹增加亮点。- 参数
-
g- 图形
-
paintTrack
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds)
画轨道。- 参数
-
g- 图形 -
c- 组件 -
trackBounds- 轨道边界
-
paintThumb
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds)
画拇指- 参数
-
g- 图形 -
c- 组件 -
thumbBounds- 拇指界限
-
getMinimumThumbSize
protected Dimension getMinimumThumbSize()
返回拇指的最小可接受尺寸。 如果滚动条变得如此之小,以至于此大小不可用,拇指将被隐藏。警告 :此方法返回的值不应该被修改,它是一个共享静态常量。
- 结果
- 拇指的最小可接受尺寸。
- 另请参见:
-
getMaximumThumbSize()
-
getMaximumThumbSize
protected Dimension getMaximumThumbSize()
返回拇指的最大可接受尺寸。 要创建一个固定大小的拇指,使这个方法和getMinimumThumbSize返回相同的值。警告 :此方法返回的值不应该被修改,它是一个共享静态常量。
- 结果
- 拇指的最大可接受尺寸。
- 另请参见:
-
getMinimumThumbSize()
-
addLayoutComponent
public void addLayoutComponent(String name, Component child)
描述从接口LayoutManager复制如果布局管理器使用每个组件字符串,则将组件comp添加到布局,将其与name指定的字符串相关联。- Specified by:
-
addLayoutComponent在接口LayoutManager - 参数
-
name- 与组件关联的字符串 -
child- 要添加的组件
-
removeLayoutComponent
public void removeLayoutComponent(Component child)
描述从接口LayoutManager复制从布局中删除指定的组件。- Specified by:
-
removeLayoutComponent在接口LayoutManager - 参数
-
child- 要删除的组件
-
preferredLayoutSize
public Dimension preferredLayoutSize(Container scrollbarContainer)
描述从接口LayoutManager复制计算指定容器的首选大小尺寸,给定其包含的组件。- Specified by:
-
preferredLayoutSize在接口LayoutManager - 参数
-
scrollbarContainer- 要布置的容器 - 结果
- 容器的首选尺寸
- 另请参见:
-
LayoutManager.minimumLayoutSize(java.awt.Container)
-
minimumLayoutSize
public Dimension minimumLayoutSize(Container scrollbarContainer)
说明从界面:LayoutManager复制计算指定容器的最小尺寸尺寸,给定其包含的组件。- Specified by:
-
minimumLayoutSize在接口LayoutManager - 参数
-
scrollbarContainer- 要布局的组件 - 结果
- 容器的最小尺寸
- 另请参见:
-
LayoutManager.preferredLayoutSize(java.awt.Container)
-
layoutVScrollbar
protected void layoutVScrollbar(JScrollBar sb)
垂直滚动条。- 参数
-
sb- 滚动条
-
layoutHScrollbar
protected void layoutHScrollbar(JScrollBar sb)
垂直滚动条。- 参数
-
sb- 滚动条
-
layoutContainer
public void layoutContainer(Container scrollbarContainer)
说明从接口LayoutManager复制放出指定的容器。- Specified by:
-
layoutContainer在接口LayoutManager - 参数
-
scrollbarContainer- 要布置的容器
-
setThumbBounds
protected void setThumbBounds(int x, int y, int width, int height)设置拇指的边界,并强制包含旧的thumbBounds和新的thumbBounds的重绘。- 参数
-
x- 设置拇指的x位置 -
y- 设置拇指的y位置 -
width- 设置拇指的宽度 -
height- 设置拇指的高度 - 另请参见:
-
getThumbBounds()
-
getThumbBounds
protected Rectangle getThumbBounds()
返回当前的大小/位置。警告 :此方法返回的值不应被修改,它是对实际矩形的引用,而不是副本。
- 结果
- 当前大小/拇指的位置。
- 另请参见:
-
setThumbBounds(int, int, int, int)
-
getTrackBounds
protected Rectangle getTrackBounds()
返回轨道的当前边界,即增量和减量按钮之间的空间,减去插值。 每次滚动条布局(验证)时,此方法返回的值都会更新。警告 :此方法返回的值不应被修改,它是对实际矩形的引用,而不是副本。
- 结果
- 滚动条轨迹的当前界限
- 另请参见:
-
layoutContainer(java.awt.Container)
-
scrollByBlock
protected void scrollByBlock(int direction)
逐块滚动- 参数
-
direction- 滚动的方向
-
scrollByUnit
protected void scrollByUnit(int direction)
按单位滚动- 参数
-
direction- 滚动的方向
-
getSupportsAbsolutePositioning
public boolean getSupportsAbsolutePositioning()
指示用户是否可以用鼠标手势(通常是鼠标中键)绝对定位拇指。- 结果
- 如果鼠标手势可以绝对定位拇指,则为true
- 从以下版本开始:
- 1.5
-
-