JavaTM 2 Platform
Standard Ed. 6

javax.swing.plaf.basic
类 BasicSliderUI

java.lang.Object
  继承者 javax.swing.plaf.ComponentUI
      继承者 javax.swing.plaf.SliderUI
          继承者 javax.swing.plaf.basic.BasicSliderUI
直接已知子类:
MetalSliderUI

public class BasicSliderUI
extends SliderUI

SliderUI 的基本 L&F 实现。


嵌套类摘要
 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
          跟踪鼠标移动。
 
字段摘要
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
           
 
构造方法摘要
BasicSliderUI(JSlider b)
           
 
方法摘要
protected  void calculateContentRect()
           
protected  void calculateFocusRect()
           
protected  void calculateGeometry()
           
protected  void calculateLabelRect()
           
protected  void calculateThumbLocation()
           
protected  void calculateThumbSize()
           
protected  void calculateTickRect()
           
protected  void calculateTrackBuffer()
           
protected  void calculateTrackRect()
           
protected  ChangeListener createChangeListener(JSlider slider)
           
protected  ComponentListener createComponentListener(JSlider slider)
           
protected  FocusListener createFocusListener(JSlider slider)
           
protected  PropertyChangeListener createPropertyChangeListener(JSlider slider)
           
protected  BasicSliderUI.ScrollListener createScrollListener(JSlider slider)
           
protected  BasicSliderUI.TrackListener createTrackListener(JSlider slider)
           
static ComponentUI createUI(JComponent b)
           
protected  boolean drawInverted()
           
 int getBaseline(JComponent c, int width, int height)
          返回基线。
 Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
          返回一个枚举,它指示该组件的基线如何随大小的改变而发生更改。
protected  Color getFocusColor()
           
protected  int getHeightOfHighValueLabel()
           
protected  int getHeightOfLowValueLabel()
           
protected  int getHeightOfTallestLabel()
           
protected  Integer getHighestValue()
          返回在标签表中有一个项的最大值。
protected  Component getHighestValueLabel()
          返回与标签表中的最低滑块值相对应的标签。
protected  Color getHighlightColor()
           
protected  Integer getLowestValue()
          返回在标签表中有一个项的最小值。
protected  Component getLowestValueLabel()
          返回与标签表中的最高滑块值相对应的标签。
 Dimension getMaximumSize(JComponent c)
          返回指定组件的适合外观的最大大小。
 Dimension getMinimumHorizontalSize()
           
 Dimension getMinimumSize(JComponent c)
          返回指定组件的适合外观的最小大小。
 Dimension getMinimumVerticalSize()
           
 Dimension getPreferredHorizontalSize()
           
 Dimension getPreferredSize(JComponent c)
          返回指定组件的适合外观的首选大小。
 Dimension getPreferredVerticalSize()
           
protected  Color getShadowColor()
           
protected  Dimension getThumbSize()
           
protected  int getTickLength()
          获取水平滑块的刻度区域的高度和垂直滑块的刻度区域的宽度。
protected  int getWidthOfHighValueLabel()
           
protected  int getWidthOfLowValueLabel()
           
protected  int getWidthOfWidestLabel()
           
protected  void installDefaults(JSlider slider)
           
protected  void installKeyboardActions(JSlider slider)
           
protected  void installListeners(JSlider slider)
           
 void installUI(JComponent c)
          配置指定组件,使其适合外观。
protected  boolean isDragging()
          如果用户在拖动滑块,则返回 true。
protected  boolean labelsHaveSameBaselines()
          如果标签表中的所有标签具有相同的基线,则返回 true。
 void paint(Graphics g, JComponent c)
          绘制指定组件,使其适合外观。
 void paintFocus(Graphics g)
           
protected  void paintHorizontalLabel(Graphics g, int value, Component label)
          为标签表中的每个标签调用此方法。
 void paintLabels(Graphics g)
           
protected  void paintMajorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x)
           
protected  void paintMajorTickForVertSlider(Graphics g, Rectangle tickBounds, int y)
           
protected  void paintMinorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x)
           
protected  void paintMinorTickForVertSlider(Graphics g, Rectangle tickBounds, int y)
           
 void paintThumb(Graphics g)
           
 void paintTicks(Graphics g)
           
 void paintTrack(Graphics g)
           
protected  void paintVerticalLabel(Graphics g, int value, Component label)
          为标签表中的每个标签调用此方法。
protected  void recalculateIfInsetsChanged()
           
protected  void recalculateIfOrientationChanged()
           
 void scrollByBlock(int direction)
           
 void scrollByUnit(int direction)
           
protected  void scrollDueToClickInTrack(int dir)
          在滑道(而非 thumb)中检测到 mousePressed 时调用此方法。
 void setThumbLocation(int x, int y)
           
protected  void uninstallKeyboardActions(JSlider slider)
           
protected  void uninstallListeners(JSlider slider)
           
 void uninstallUI(JComponent c)
          在 installUI 期间,在指定组件上反向执行的配置操作。
 int valueForXPosition(int xPos)
          返回给出 x 位置的值。
 int valueForYPosition(int yPos)
          返回给出 y 位置的值。
protected  int xPositionForValue(int value)
           
protected  int yPositionForValue(int value)
           
protected  int yPositionForValue(int value, int trackY, int trackHeight)
          返回指定值的 y 位置。
 
从类 javax.swing.plaf.ComponentUI 继承的方法
contains, getAccessibleChild, getAccessibleChildrenCount, update
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

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

protected Timer scrollTimer

slider

protected JSlider slider

focusInsets

protected Insets focusInsets

insetCache

protected Insets insetCache

leftToRightCache

protected boolean leftToRightCache

focusRect

protected Rectangle focusRect

contentRect

protected Rectangle contentRect

labelRect

protected Rectangle labelRect

tickRect

protected Rectangle tickRect

trackRect

protected Rectangle trackRect

thumbRect

protected Rectangle thumbRect

trackBuffer

protected int trackBuffer

trackListener

protected BasicSliderUI.TrackListener trackListener

changeListener

protected ChangeListener changeListener

componentListener

protected ComponentListener componentListener

focusListener

protected FocusListener focusListener

scrollListener

protected BasicSliderUI.ScrollListener scrollListener

propertyChangeListener

protected PropertyChangeListener propertyChangeListener
构造方法详细信息

BasicSliderUI

public BasicSliderUI(JSlider b)
方法详细信息

getShadowColor

protected Color getShadowColor()

getHighlightColor

protected Color getHighlightColor()

getFocusColor

protected Color getFocusColor()

isDragging

protected boolean isDragging()
如果用户在拖动滑块,则返回 true。

返回:
如果用户在拖动滑块,则返回 true
从以下版本开始:
1.5

createUI

public static ComponentUI createUI(JComponent b)

installUI

public void installUI(JComponent c)
从类 ComponentUI 复制的描述
配置指定组件,使其适合外观。当 ComponentUI 实例将作为 UI 委托安装在指定组件上时,可调用此方法。此方法应该为外观完整地配置组件,包括以下方面:
  1. 在组件上安装用于颜色、字体、边框、图标、不透明性等方面的所有默认属性值。只要有可能,就 应该重写由客户端程序初始化的属性值。
  2. 如有必要,可在组件上安装一个 LayoutManager
  3. 将所需的所有子组件创建/添加到组件中。
  4. 在组件上创建/安装事件侦听器。
  5. 为了检测和适当响应组件属性更改,可在组件上创建/安装一个 PropertyChangeListener
  6. 在组件上安装键盘 UI(助记符、遍历等等)。
  7. 初始化任何适当的实例数据。

覆盖:
ComponentUI 中的 installUI
参数:
c - 将安装此 UI 委托的组件
另请参见:
ComponentUI.uninstallUI(javax.swing.JComponent), JComponent.setUI(javax.swing.plaf.ComponentUI), JComponent.updateUI()

uninstallUI

public void uninstallUI(JComponent c)
从类 ComponentUI 复制的描述
installUI 期间,在指定组件上反向执行的配置操作。当此 UIComponent 实例将作为 UI 委托从指定组件上移除时,可调用此方法。此方法应该取消在 installUI 中执行的配置操作,非常小心地使 JComponent 实例处于某种洁净状态(没有额外的侦听器、没有特定于外观的属性对象等等)。配置内容应该包括以下方面:
  1. 从组件中移除所有 UI 设置的边框。
  2. 从组件上移除所有 UI 设置的布局管理器。
  3. 从组件中移除所有 UI 添加的子组件。
  4. 从组件中移除所有 UI 添加的事件/属性侦听器。
  5. 从组件中移除所有 UI 安装的键盘 UI。
  6. 使所有已分配的实例数据对象无效,从而允许进行 GC 操作。

覆盖:
ComponentUI 中的 uninstallUI
参数:
c - 从中移除此 UI 委托的组件;此参数常被忽略,但如果 UI 对象是无状态的并由多个组件共享,则可以使用该参数
另请参见:
ComponentUI.installUI(javax.swing.JComponent), JComponent.updateUI()

installDefaults

protected void installDefaults(JSlider slider)

createTrackListener

protected BasicSliderUI.TrackListener createTrackListener(JSlider slider)

createChangeListener

protected ChangeListener createChangeListener(JSlider slider)

createComponentListener

protected ComponentListener createComponentListener(JSlider slider)

createFocusListener

protected FocusListener createFocusListener(JSlider slider)

createScrollListener

protected BasicSliderUI.ScrollListener createScrollListener(JSlider slider)

createPropertyChangeListener

protected PropertyChangeListener createPropertyChangeListener(JSlider slider)

installListeners

protected void installListeners(JSlider slider)

uninstallListeners

protected void uninstallListeners(JSlider slider)

installKeyboardActions

protected void installKeyboardActions(JSlider slider)

uninstallKeyboardActions

protected void uninstallKeyboardActions(JSlider slider)

getBaseline

public int getBaseline(JComponent c,
                       int width,
                       int height)
返回基线。

覆盖:
ComponentUI 中的 getBaseline
参数:
c - 为其请求基线的 JComponent
width - 为其获取基线的宽度
height - 为其获取基线的高度
返回:
基线;如果没有合理的基线,则返回 < 0 的值
抛出:
NullPointerException - 如果 cnull
IllegalArgumentException - 如果宽度或高度 < 0
从以下版本开始:
1.6
另请参见:
JComponent.getBaseline(int, int)

getBaselineResizeBehavior

public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
返回一个枚举,它指示该组件的基线如何随大小的改变而发生更改。

覆盖:
ComponentUI 中的 getBaselineResizeBehavior
参数:
c - 为其返回调整大小行为的 JComponent
返回:
一个枚举,指示基线如何随组件大小的改变而发生更改
抛出:
NullPointerException - 如果 cnull
从以下版本开始:
1.6
另请参见:
JComponent.getBaseline(int, int)

labelsHaveSameBaselines

protected boolean labelsHaveSameBaselines()
如果标签表中的所有标签具有相同的基线,则返回 true。

返回:
如果标签表中的所有标签具有相同的基线,则返回 true
从以下版本开始:
1.6

getPreferredHorizontalSize

public Dimension getPreferredHorizontalSize()

getPreferredVerticalSize

public Dimension getPreferredVerticalSize()

getMinimumHorizontalSize

public Dimension getMinimumHorizontalSize()

getMinimumVerticalSize

public Dimension getMinimumVerticalSize()

getPreferredSize

public Dimension getPreferredSize(JComponent c)
从类 ComponentUI 复制的描述
返回指定组件的适合外观的首选大小。如果返回 null,则首选大小将由组件的布局管理器计算(对于安装了特定布局管理器的组件而言,这是首选方法)。此方法的默认实现返回 null

覆盖:
ComponentUI 中的 getPreferredSize
参数:
c - 将查询其首选大小的组件;此参数常被忽略,但如果 UI 对象是无状态的并由多个组件共享,则可以使用该参数
另请参见:
JComponent.getPreferredSize(), LayoutManager.preferredLayoutSize(java.awt.Container)

getMinimumSize

public Dimension getMinimumSize(JComponent c)
从类 ComponentUI 复制的描述
返回指定组件的适合外观的最小大小。如果返回 null,则最小大小将由组件的布局管理器计算(对于安装了特定布局管理器的组件而言,这是首选方法)。此方法的默认实现调用 getPreferredSize 并返回该值。

覆盖:
ComponentUI 中的 getMinimumSize
参数:
c - 将查询其最小大小的组件;此参数常被忽略,但如果 UI 对象是无状态的并由多个组件共享,则可以使用该参数
返回:
一个 Dimension 对象或 null
另请参见:
JComponent.getMinimumSize(), LayoutManager.minimumLayoutSize(java.awt.Container), ComponentUI.getPreferredSize(javax.swing.JComponent)

getMaximumSize

public Dimension getMaximumSize(JComponent c)
从类 ComponentUI 复制的描述
返回指定组件的适合外观的最大大小。如果返回 null,则最大大小将由组件的布局管理器计算(对于安装了特定布局管理器的组件而言,这是首选方法)。此方法的默认实现调用 getPreferredSize 并返回该值。

覆盖:
ComponentUI 中的 getMaximumSize
参数:
c - 将查询其最大大小的组件;此参数常被忽略,但如果 UI 对象是无状态的并由多个组件共享,则可以使用该参数
返回:
一个 Dimension 对象或 null
另请参见:
JComponent.getMaximumSize(), LayoutManager2.maximumLayoutSize(java.awt.Container)

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

protected Dimension 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

protected Integer getHighestValue()
返回在标签表中有一个项的最大值。

返回:
在标签表中有一个项的最大值,或则返回 null。
从以下版本开始:
1.6

getLowestValue

protected Integer getLowestValue()
返回在标签表中有一个项的最小值。

返回:
在标签表中有一个项的最小值,或则返回 null。
从以下版本开始:
1.6

getLowestValueLabel

protected Component getLowestValueLabel()
返回与标签表中的最高滑块值相对应的标签。

另请参见:
JSlider.setLabelTable(java.util.Dictionary)

getHighestValueLabel

protected Component getHighestValueLabel()
返回与标签表中的最低滑块值相对应的标签。

另请参见:
JSlider.setLabelTable(java.util.Dictionary)

paint

public void paint(Graphics g,
                  JComponent c)
从类 ComponentUI 复制的描述
绘制指定组件,使其适合外观。在将要绘制指定组件时,从 ComponentUI.update 方法中调用此方法。子类应该重写此方法并使用指定 Graphics 对象来呈现组件的内容。

覆盖:
ComponentUI 中的 paint
参数:
g - 将在其中进行绘制的 Graphics 上下文
c - 将绘制的组件;此参数常被忽略,但如果 UI 对象是无状态的并由多个组件共享,则可以使用该参数
另请参见:
ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)

recalculateIfInsetsChanged

protected void recalculateIfInsetsChanged()

recalculateIfOrientationChanged

protected void recalculateIfOrientationChanged()

paintFocus

public void paintFocus(Graphics g)

paintTrack

public void paintTrack(Graphics g)

paintTicks

public void paintTicks(Graphics g)

paintMinorTickForHorizSlider

protected void paintMinorTickForHorizSlider(Graphics g,
                                            Rectangle tickBounds,
                                            int x)

paintMajorTickForHorizSlider

protected void paintMajorTickForHorizSlider(Graphics g,
                                            Rectangle tickBounds,
                                            int x)

paintMinorTickForVertSlider

protected void paintMinorTickForVertSlider(Graphics g,
                                           Rectangle tickBounds,
                                           int y)

paintMajorTickForVertSlider

protected void paintMajorTickForVertSlider(Graphics g,
                                           Rectangle tickBounds,
                                           int y)

paintLabels

public void paintLabels(Graphics g)

paintHorizontalLabel

protected void paintHorizontalLabel(Graphics g,
                                    int value,
                                    Component label)
为标签表中的每个标签调用此方法。用于绘制水平滑块的标签。已将图形转换为 labelRect.y。

另请参见:
JSlider.setLabelTable(java.util.Dictionary)

paintVerticalLabel

protected void paintVerticalLabel(Graphics g,
                                  int value,
                                  Component label)
为标签表中的每个标签调用此方法。用于绘制垂直平滑块的标签。已将图形转换为 labelRect.x。

另请参见:
JSlider.setLabelTable(java.util.Dictionary)

paintThumb

public void paintThumb(Graphics g)

setThumbLocation

public void setThumbLocation(int x,
                             int y)

scrollByBlock

public void scrollByBlock(int direction)

scrollByUnit

public void scrollByUnit(int direction)

scrollDueToClickInTrack

protected void scrollDueToClickInTrack(int dir)
在滑道(而非 thumb)中检测到 mousePressed 时调用此方法。默认行为按块滚动。可以重写此方法来阻止滚动或者添加其他行为。


xPositionForValue

protected int xPositionForValue(int value)

yPositionForValue

protected int yPositionForValue(int value)

yPositionForValue

protected int yPositionForValue(int value,
                                int trackY,
                                int trackHeight)
返回指定值的 y 位置。不对该参数进行检查。尤其是,如果 trackHeight 负数,则结果是不确定的。

参数:
value - 要获取其位置的滑块值
trackY - 滑道 y 原点
trackHeight - 滑道高度
从以下版本开始:
1.6

valueForYPosition

public int valueForYPosition(int yPos)
返回给出 y 位置的值。如果 yPos 越过了滑道顶部或底部,则它会将该值设置为滑块的最小值或最大值,这一点取决于是否反转了滑块。


valueForXPosition

public int valueForXPosition(int xPos)
返回给出 x 位置的值。如果 xPos 越过了滑道左边或右边,则它会将该值设置为滑块的最小值或最大值,这一点取决于是否了反转滑块。


JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only