public class JScrollBar extends JComponent implements Adjustable, Accessible
通常,由于滚动条中的旋钮的位置改变了对基础视图上JViewport的位置的相应更改,从而更改了JViewport的内容。
警告: Swing不是线程安全的。 有关更多信息,请参阅Swing's Threading Policy 。
警告:此类的序列化对象与将来的Swing版本不兼容。 当前的序列化支持适用于运行相同版本的Swing的应用程序之间的短期存储或RMI。 从1.4开始,对所有JavaBeans的长期存储的支持已经添加到java.beans
包中。 请参阅XMLEncoder
。
JScrollPane
Modifier and Type | Class and Description |
---|---|
protected class |
JScrollBar.AccessibleJScrollBar
这个类实现了可访问性支持
JScrollBar 类。
|
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
protected int |
blockIncrement |
protected BoundedRangeModel |
model
代表滚动条最小值,最大值,范围(又称“visibleAmount”)和当前值的模型。
|
protected int |
orientation |
protected int |
unitIncrement |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
HORIZONTAL, NO_ORIENTATION, VERTICAL
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
JScrollBar()
创建具有以下初始值的垂直滚动条:
|
JScrollBar(int orientation)
创建具有指定方向和以下初始值的滚动条:
|
JScrollBar(int orientation, int value, int extent, int min, int max)
创建具有指定方向,值,范围,最小值和最大值的滚动条。
|
Modifier and Type | Method and Description |
---|---|
void |
addAdjustmentListener(AdjustmentListener l)
添加一个AdjustmentListener。
|
protected void |
fireAdjustmentValueChanged(int id, int type, int value)
通知听众滚动条的模型已更改。
|
AccessibleContext |
getAccessibleContext()
获取与此JScrollBar关联的AccessibleContext。
|
AdjustmentListener[] |
getAdjustmentListeners()
返回使用addAdjustmentListener()添加到此JScrollBar的所有
AdjustmentListener 的数组。
|
int |
getBlockIncrement()
为了向后兼容java.awt.Scrollbar。
|
int |
getBlockIncrement(int direction)
给定一个块(通常是“页”)上/下请求,返回滚动条的值的值。
|
int |
getMaximum()
滚动条的最大值是最大值。
|
Dimension |
getMaximumSize()
滚动条沿其滚动轴线是柔性的,并且沿着另一个轴线是刚性的。
|
int |
getMinimum()
返回滚动条支持的最小值(通常为零)。
|
Dimension |
getMinimumSize()
滚动条沿其滚动轴线是柔性的,并且沿着另一个轴线是刚性的。
|
BoundedRangeModel |
getModel()
返回处理滚动条的四个基本属性的数据模型:minimum,maximum,value,extent。
|
int |
getOrientation()
返回组件的方向(水平或垂直)。
|
ScrollBarUI |
getUI()
返回实现该组件外观的委托。
|
String |
getUIClassID()
返回此组件的LookAndFeel类的名称。
|
int |
getUnitIncrement()
为了向后兼容java.awt.Scrollbar。
|
int |
getUnitIncrement(int direction)
给出单位加/减请求,返回滚动条的值的更改量。
|
int |
getValue()
返回滚动条的值。
|
boolean |
getValueIsAdjusting()
如果滚动条旋钮被拖动,则为真。
|
int |
getVisibleAmount()
返回滚动条的范围,又称为“visibleAmount”。
|
protected String |
paramString()
返回此JScrollBar的字符串表示形式。
|
void |
removeAdjustmentListener(AdjustmentListener l)
删除AdjustmentEvent侦听器。
|
void |
setBlockIncrement(int blockIncrement)
设置blockIncrement属性。
|
void |
setEnabled(boolean x)
启用组件,以便可以更改旋钮位置。
|
void |
setMaximum(int maximum)
设置模型的最大属性。
|
void |
setMinimum(int minimum)
设置模型的最小属性。
|
void |
setModel(BoundedRangeModel newModel)
设置处理滚动条的四个基本属性的模型:minimum,maximum,value,extent。
|
void |
setOrientation(int orientation)
将滚动条的方向设置为VERTICAL或HORIZONTAL。
|
void |
setUI(ScrollBarUI ui)
设置渲染此组件的L&F对象。
|
void |
setUnitIncrement(int unitIncrement)
设置unitIncrement属性。
|
void |
setValue(int value)
设置滚动条的值。
|
void |
setValueIsAdjusting(boolean b)
设置模型的valueIsAdjusting属性。
|
void |
setValues(int newValue, int newExtent, int newMin, int newMax)
强制参数遵循通常的约束,设置四个BoundedRangeModel属性:
|
void |
setVisibleAmount(int extent)
设置模型的扩展属性。
|
void |
updateUI()
覆盖
JComponent.updateUI 。
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
protected BoundedRangeModel model
protected int orientation
setOrientation(int)
protected int unitIncrement
setUnitIncrement(int)
protected int blockIncrement
setBlockIncrement(int)
public JScrollBar(int orientation, int value, int extent, int min, int max)
注意:使用setBlockIncrement
将块增量设置为略小于视图范围的大小。 这样,当用户将旋钮跳到相邻位置时,原始内容的一行或两行仍然保留在视图中。
IllegalArgumentException
- 如果方向不是VERTICAL,HORIZONTAL之一
setOrientation(int)
,
setValue(int)
,
setVisibleAmount(int)
,
setMinimum(int)
,
setMaximum(int)
public JScrollBar(int orientation)
minimum = 0
maximum = 100
value = 0
extent = 10
public JScrollBar()
minimum = 0
maximum = 100
value = 0
extent = 10
public void setUI(ScrollBarUI ui)
ui
-
ScrollBarUI
L&F对象
UIDefaults.getUI(javax.swing.JComponent)
public ScrollBarUI getUI()
public void updateUI()
JComponent.updateUI
。
updateUI
在类
JComponent
JComponent.updateUI()
public String getUIClassID()
getUIClassID
在
JComponent
JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)
public int getOrientation()
getOrientation
在接口
Adjustable
setOrientation(int)
,
Adjustable.getOrientation()
public void setOrientation(int orientation)
IllegalArgumentException
- 如果方位不是垂直的,水平的
getOrientation()
public BoundedRangeModel getModel()
public void setModel(BoundedRangeModel newModel)
getModel()
public int getUnitIncrement(int direction)
JScrollPane组件创建滚动条(默认情况下)覆盖此方法,并委托给视口Scrollable视图(如果有)。 Scrollable界面提供了这种方法的更专门的版本。
一些外观和感觉实现自定义滚动行为,并忽略此属性。
direction
- 分别为-1或1
setUnitIncrement(int)
,
setValue(int)
,
Scrollable.getScrollableUnitIncrement(java.awt.Rectangle, int, int)
public void setUnitIncrement(int unitIncrement)
请注意,如果参数等于Integer.MIN_VALUE的值,最多的外观和感觉不会提供向右/向下的滚动。
一些外观和感觉实现自定义滚动行为,并忽略此属性。
setUnitIncrement
在接口
Adjustable
unitIncrement
- 单位增量
getUnitIncrement(int)
public int getBlockIncrement(int direction)
JScrollPane组件创建滚动条(默认情况下)覆盖此方法,并委托给视口Scrollable视图(如果有)。 Scrollable界面提供了这种方法的更专门的版本。
一些外观和感觉实现自定义滚动行为,并忽略此属性。
direction
- 分别为-1或1
setBlockIncrement(int)
,
setValue(int)
,
Scrollable.getScrollableBlockIncrement(java.awt.Rectangle, int, int)
public void setBlockIncrement(int blockIncrement)
请注意,如果参数等于Integer.MIN_VALUE的值,最多的外观和感觉不会提供向右/向下的滚动。
一些外观和感觉实现自定义滚动行为,并忽略此属性。
setBlockIncrement
在界面
Adjustable
blockIncrement
- 块增量
getBlockIncrement()
public int getUnitIncrement()
getUnitIncrement
在接口
Adjustable
Adjustable.getUnitIncrement()
,
getUnitIncrement(int)
public int getBlockIncrement()
getBlockIncrement
在界面
Adjustable
Adjustable.getBlockIncrement()
,
getBlockIncrement(int)
public int getValue()
getValue
在界面
Adjustable
setValue(int)
public void setValue(int value)
setValue
在界面
Adjustable
value
- 当前值,介于
minimum
和
maximum
-
visibleAmount
getValue()
,
BoundedRangeModel.setValue(int)
public int getVisibleAmount()
getVisibleAmount
在界面
Adjustable
setVisibleAmount(int)
public void setVisibleAmount(int extent)
setVisibleAmount
在接口
Adjustable
extent
-
extent
的长度
getVisibleAmount()
,
BoundedRangeModel.setExtent(int)
public int getMinimum()
getMinimum
在界面
Adjustable
setMinimum(int)
public void setMinimum(int minimum)
setMinimum
在接口
Adjustable
minimum
- 最小值
getMinimum()
,
BoundedRangeModel.setMinimum(int)
public int getMaximum()
getMaximum
在接口
Adjustable
setMaximum(int)
public void setMaximum(int maximum)
setMaximum
在接口
Adjustable
maximum
- 最大值
getMaximum()
,
BoundedRangeModel.setMaximum(int)
public boolean getValueIsAdjusting()
setValueIsAdjusting(boolean)
public void setValueIsAdjusting(boolean b)
public void setValues(int newValue, int newExtent, int newMin, int newMax)
minimum ≤ value ≤ value+extent ≤ maximum
public void addAdjustmentListener(AdjustmentListener l)
请注意,AdjustmentEvents type属性将始终具有AdjustmentEvent.TRACK的占位符值,因为对BoundedRangeModels值的所有更改都被视为等效的。 要更改BoundedRangeModel的值,只需设置其value属性,即model.setValue(123)。 没有提供关于变更起源的信息,例如它是一个块减量。 我们不尝试制造这里的变化的起源。
addAdjustmentListener
在接口
Adjustable
l
- 要添加的AdjustmentLister
removeAdjustmentListener(java.awt.event.AdjustmentListener)
,
BoundedRangeModel.addChangeListener(javax.swing.event.ChangeListener)
public void removeAdjustmentListener(AdjustmentListener l)
removeAdjustmentListener
在接口
Adjustable
l
- 要删除的AdjustmentLister
addAdjustmentListener(java.awt.event.AdjustmentListener)
public AdjustmentListener[] getAdjustmentListeners()
AdjustmentListener
的数组。
AdjustmentListener
如果没有添加侦听器,则为空数组
protected void fireAdjustmentValueChanged(int id, int type, int value)
public Dimension getMinimumSize()
getMinimumSize
在
JComponent
minimumSize
属性
JComponent.setMinimumSize(java.awt.Dimension)
, ComponentUI
public Dimension getMaximumSize()
getMaximumSize
在
JComponent
类
maximumSize
属性
JComponent.setMaximumSize(java.awt.Dimension)
, ComponentUI
public void setEnabled(boolean x)
setEnabled
在
JComponent
x
- 一个布尔值,其中true使组件和false禁用它
Component.isEnabled()
,
Component.isLightweight()
protected String paramString()
null
。
paramString
在
JComponent
public AccessibleContext getAccessibleContext()
getAccessibleContext
在界面
Accessible
getAccessibleContext
在
Component
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.