javax.swing

接口
异常
java.lang.Object
  继承者 java.awt.Component
      继承者 java.awt.Container
          继承者 javax.swing.JComponent
              继承者 javax.swing.JScrollBar
所有已实现的接口:
Adjustable, ImageObserver, MenuContainer, Serializable, Accessible
直接已知子类:
JScrollPane.ScrollBar

public class JScrollBar
     
extends JComponent
implements Adjustable, Accessible

滚动条的实现。用户在滚动条内移动滑块可确定显示区域中的内容。该程序通常将显示调整为滚动条的结束代表可显示内容的结束,或内容的 100%。滚动条的开始为可显示内容的开始,或 0%。然后滑块在其边界中的位置转换为可显示内容对应的百分比。

通常,随着滑块的位置在滚动条中的变化,将在基础视图上对 JViewport 的位置进行相应的更改,这样 JViewport 的内容也随之改变。

警告:Swing 不是线程安全的。有关更多信息,请参阅 Swing's Threading Policy

警告:此类的序列化对象与以后的 Swing 版本不兼容。当前序列化支持适用于短期存储,或适用于在运行相同 Swing 版本的应用程序之间进行 RMI(Remote Method Invocation,远程方法调用)。从 1.4 版本开始,已在 java.beans 包中添加了支持所有 JavaBeansTM 长期存储的功能。请参见 XMLEncoder

另请参见:
JScrollPane

嵌套类摘要
protected  class JScrollBar.AccessibleJScrollBar
          此类实现 JScrollBar 类的可访问性支持。
 
从类 javax.swing.JComponent 继承的嵌套类/接口
JComponent.AccessibleJComponent
 
从类 java.awt.Container 继承的嵌套类/接口
Container.AccessibleAWTContainer
 
从类 java.awt.Component 继承的嵌套类/接口
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
字段摘要
protected  int blockIncrement
           
protected  BoundedRangeModel model
          表示滚动条的最小、最大、跨度(也叫 "visibleAmount")和当前值的模型。
protected  int orientation
           
protected  int unitIncrement
           
 
从类 javax.swing.JComponent 继承的字段
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
从类 java.awt.Component 继承的字段
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
从接口 java.awt.Adjustable 继承的字段
HORIZONTAL, NO_ORIENTATION, VERTICAL
 
从接口 java.awt.image.ImageObserver 继承的字段
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
构造方法摘要
JScrollBar()
          创建具有下列初始值的垂直滚动条:
JScrollBar(int orientation)
          创建具有指定方向和下列初始值的滚动条:
JScrollBar(int orientation, int value, int extent, int min, int max)
          创建具有指定方向、值、跨度、最小值和最大值的一个滚动条。
 
方法摘要
 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)
          针对一个向上/向下滚动一个块(通常为 "page")的请求,返回滚动条值的更改量。
 int getMaximum()
          滚动条的最大值为最大跨度。
 Dimension getMaximumSize()
          滚动条沿其滚动轴具有弹性,沿另一个轴具有刚性。
 int getMinimum()
          返回滚动条支持的最小值(通常为 0)。
 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()
          如果滚动条滑块被拖动,则返回 True。
 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)
          设置模型的 maximum 属性。
 void setMinimum(int minimum)
          设置模型的 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)
          设置模型的 extent 属性。
 void updateUI()
          重写 JComponent.updateUI
 
从类 javax.swing.JComponent 继承的方法
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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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
 
从类 java.awt.Container 继承的方法
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, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
从类 java.awt.Component 继承的方法
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, hide, 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, transferFocusUpCycle
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

字段详细信息

model

protected BoundedRangeModel model
表示滚动条的最小、最大、跨度(也叫 "visibleAmount")和当前值的模型。

另请参见:
setModel(javax.swing.BoundedRangeModel)

orientation

protected int orientation
另请参见:
setOrientation(int)

unitIncrement

protected int unitIncrement
另请参见:
setUnitIncrement(int)

blockIncrement

protected int blockIncrement
另请参见:
setBlockIncrement(int)
构造方法详细信息<

JDK 1.6 中文手册