Typically, as the position of the knob in the scrollbar changes a corresponding change is made to the position of the JViewport on the underlying view, changing the contents of the JViewport.
Warning
Swing is not thread safe. For more information see Swing's Threading Policy.
Warning
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans package.
Please see java..
JScrollPane
| Modifier and Type | Class and Description |
|---|---|
| protected class | JScrollBar.
This class implements accessibility support for the
|
| private class | JScrollBar.
This class listens to ChangeEvents on the model and forwards AdjustmentEvents for the sake of backwards compatibility. |
| Modifier and Type | Field and Description |
|---|---|
| protected int | blockIncrement
Stores the amount by which the value of the scrollbar is changed upon a block (usually "page") up/down request. |
| private ChangeListener | fwdAdjustmentEvents
All changes from the model are treated as though the user moved the scrollbar knob. |
| protected BoundedRangeModel | model
The model that represents the scrollbar's minimum, maximum, extent (aka "visibleAmount") and current value. |
| protected int | orientation
Orientation of this scrollBar. |
| private static final String | |
| protected int | unitIncrement
Stores the amount by which the value of the scrollbar is changed upon a unit up/down request. |
| Access | Constructor and Description |
|---|---|
| public | JScrollBar(int
an orientation of the orientation, int JScrollBaran int giving the current value value, int an int giving the amount by which the value can "jump" extent, int an int giving the minimum value min, int an int giving the maximum value max)Creates a scrollbar with the specified orientation, value, extent, minimum, and maximum. |
| public | JScrollBar(int
an orientation of the orientation)JScrollBarCreates a scrollbar with the specified orientation and the following initial values: minimum = 0 maximum = 100 value = 0 extent = 10 |
| public | JScrollBar()
Creates a vertical scrollbar with the following initial values: minimum = 0 maximum = 100 value = 0 extent = 10 |
| Modifier and Type | Method and Description |
|---|---|
| public void | addAdjustmentListener(AdjustmentListener
the AdjustmentLister to add l)Implements java. Adds an AdjustmentListener. |
| private void | |
| protected void | fireAdjustmentValueChanged(int
an integer indicating the type of event. id, int an integer indicating the adjustment type. type, int the current value of the adjustment value)Notify listeners that the scrollbar's model has changed. |
| private void | fireAdjustmentValueChanged(int id, int type, int value, boolean isAdjusting)
Notify listeners that the scrollbar's model has changed. |
| public AccessibleContext | Returns: an AccessibleJScrollBar that serves as the AccessibleContext of this JScrollBarOverrides java. Implements javax. Gets the AccessibleContext associated with this JScrollBar. |
| public AdjustmentListener[] | Returns: all of theAdjustmentListeners added or an empty
array if no listeners have been addedReturns an array of all the |
| public int | Returns: the value of the blockIncrement propertyis -1 or 1 for up/down respectively direction)Returns the amount to change the scrollbar's value by, given a block (usually "page") up/down request. |
| public int | getBlockIncrement()
Implements java. For backwards compatibility with java.awt.Scrollbar. |
| public int | Returns: the value of the model's maximum propertyImplements java. The maximum value of the scrollbar is maximum - extent. |
| public Dimension | Returns: the maximum size as specified aboveOverrides javax. Returns the maximum size for the |
| public int | Returns: the value of the model's minimum propertyImplements java. Returns the minimum value supported by the scrollbar (usually zero). |
| public Dimension | Returns: the minimum size as specified aboveOverrides javax. Returns the minimum size for the |
| public BoundedRangeModel | Returns: the data modelReturns data model that handles the scrollbar's four fundamental properties: minimum, maximum, value, extent. |
| public int | Returns: VERTICAL or HORIZONTALImplements java. Returns the component's orientation (horizontal or vertical). |
| public ScrollBarUI | Returns: the scroll bar's current UI.Overrides javax. Returns the delegate that implements the look and feel for this component. |
| public String | Returns: the string "ScrollBarUI"Overrides javax. Returns the name of the LookAndFeel class for this component. |
| public int | Returns: the value of the unitIncrement propertyis -1 or 1 for up/down respectively direction)Returns the amount to change the scrollbar's value by, given a unit up/down request. |
| public int | getUnitIncrement()
Implements java. For backwards compatibility with java.awt.Scrollbar. |
| public int | Returns: the model's value propertyImplements java. Returns the scrollbar's value. |
| public boolean | Returns: the value of the model's valueIsAdjusting propertyTrue if the scrollbar knob is being dragged. |
| public int | Returns: the value of the model's extent propertyImplements java. Returns the scrollbar's extent, aka its "visibleAmount". |
| protected String | Returns: a string representation of this JScrollBar.Overrides javax. Returns a string representation of this JScrollBar. |
| public void | removeAdjustmentListener(AdjustmentListener
the AdjustmentLister to remove l)Implements java. Removes an AdjustmentEvent listener. |
| public void | setBlockIncrement(int blockIncrement)
Implements java. Sets the blockIncrement property. |
| public void | setEnabled(boolean
a boolean value, where true enables the component and
false disables it x)Overrides javax. Enables the component so that the knob position can be changed. |
| public void | setMaximum(int maximum)
Implements java. Sets the model's maximum property. |
| public void | setMaximumSize(Dimension
the desired maximum allowable size maximumSize)Overrides javax. Unlike most components, |
| public void | setMinimum(int minimum)
Implements java. Sets the model's minimum property. |
| public void | setMinimumSize(Dimension
the new minimum size of this component minimumSize)Overrides javax. Unlike most components, |
| public void | setModel(BoundedRangeModel
a new model newModel)Sets the model that handles the scrollbar's four fundamental properties: minimum, maximum, value, extent. |
| public void | setOrientation(int
an orientation of the orientation)JScrollBarSet the scrollbar's orientation to either VERTICAL or HORIZONTAL. |
| public void | |
| public void | setUnitIncrement(int unitIncrement)
Implements java. Sets the unitIncrement property. |
| public void | |
| public void | setValueIsAdjusting(boolean
true if the upcoming changes to the value property are part of a seriesSets the model's valueIsAdjusting property. |
| public void | setValues(int
an int giving the current value newValue, int an int giving the amount by which the value can "jump" newExtent, int an int giving the minimum value newMin, int an int giving the maximum value newMax)Sets the four BoundedRangeModel properties after forcing the arguments to obey the usual constraints: minimum ≤ value ≤ value+extent ≤ maximum |
| public void | setVisibleAmount(int extent)
Implements java. Set the model's extent property. |
| public void | |
| private void | writeObject(ObjectOutputStream s)
Hides javax. See readObject() and writeObject() in JComponent for more information about serialization in Swing. |
| blockIncrement | back to summary |
|---|---|
| protected int blockIncrement Stores the amount by which the value of the scrollbar is changed upon a block (usually "page") up/down request.
| |
| fwdAdjustmentEvents | back to summary |
|---|---|
| private ChangeListener fwdAdjustmentEvents All changes from the model are treated as though the user moved the scrollbar knob. | |
| model | back to summary |
|---|---|
| protected BoundedRangeModel model The model that represents the scrollbar's minimum, maximum, extent (aka "visibleAmount") and current value.
| |
| orientation | back to summary |
|---|---|
| protected int orientation Orientation of this scrollBar.
| |
| uiClassID | back to summary |
|---|---|
| private static final String uiClassID Hides javax.
| |
| unitIncrement | back to summary |
|---|---|
| protected int unitIncrement Stores the amount by which the value of the scrollbar is changed upon a unit up/down request.
| |
| JScrollBar | back to summary |
|---|---|
| public JScrollBar(int orientation, int value, int extent, int min, int max) Creates a scrollbar with the specified orientation, value, extent, minimum, and maximum. The "extent" is the size of the viewable area. It is also known as the "visible amount". Note Use
| |
| JScrollBar | back to summary |
|---|---|
| public JScrollBar(int orientation) Creates a scrollbar with the specified orientation and the following initial values: minimum = 0 maximum = 100 value = 0 extent = 10
| |
| JScrollBar | back to summary |
|---|---|
| public JScrollBar() Creates a vertical scrollbar with the following initial values: minimum = 0 maximum = 100 value = 0 extent = 10 | |
| addAdjustmentListener | back to summary |
|---|---|
| public void addAdjustmentListener(AdjustmentListener l) Implements java. Adds an AdjustmentListener. Adjustment listeners are notified each time the scrollbar's model changes. Adjustment events are provided for backwards compatibility with java.awt.Scrollbar. Note that the AdjustmentEvents type property will always have a placeholder value of AdjustmentEvent.TRACK because all changes to a BoundedRangeModels value are considered equivalent. To change the value of a BoundedRangeModel one just sets its value property, i.e. model.setValue(123). No information about the origin of the change, e.g. it's a block decrement, is provided. We don't try to fabricate the origin of the change here.
| |
| checkOrientation | back to summary |
|---|---|
| private void checkOrientation(int orientation) | |
| fireAdjustmentValueChanged | back to summary |
|---|---|
| protected void fireAdjustmentValueChanged(int id, int type, int value) Notify listeners that the scrollbar's model has changed.
| |
| fireAdjustmentValueChanged | back to summary |
|---|---|
| private void fireAdjustmentValueChanged(int id, int type, int value, boolean isAdjusting) Notify listeners that the scrollbar's model has changed.
| |
| getAccessibleContext | back to summary |
|---|---|
| public AccessibleContext getAccessibleContext() Overrides java. Implements javax. Gets the AccessibleContext associated with this JScrollBar. For JScrollBar, the AccessibleContext takes the form of an AccessibleJScrollBar. A new AccessibleJScrollBar instance is created if necessary.
| |
| getAdjustmentListeners | back to summary |
|---|---|
| public AdjustmentListener[] getAdjustmentListeners() Returns an array of all the
| |
| getBlockIncrement | back to summary |
|---|---|
| public int getBlockIncrement(int direction) Returns the amount to change the scrollbar's value by, given a block (usually "page") up/down request. A ScrollBarUI implementation typically calls this method when the user clicks outside the scrollbar "knob" to scroll up or down by a large amount. Subclasses may override this method to compute a value, e.g. the change required to scroll one paragraph in a text document. The JScrollPane component creates scrollbars (by default) that override this method and delegate to the viewports Scrollable view, if it has one. The Scrollable interface provides a more specialized version of this method. Some look and feel implementations that provide custom scrolling behavior ignore this property.
| |
| getBlockIncrement | back to summary |
|---|---|
| public int getBlockIncrement() Implements java. For backwards compatibility with java.awt.Scrollbar. | |
| getMaximum | back to summary |
|---|---|
| public int getMaximum() Implements java. The maximum value of the scrollbar is maximum - extent.
| |
| getMaximumSize | back to summary |
|---|---|
| public Dimension getMaximumSize() Overrides javax. Returns the maximum size for the
| |
| getMinimum | back to summary |
|---|---|
| public int getMinimum() Implements java. Returns the minimum value supported by the scrollbar (usually zero).
| |
| getMinimumSize | back to summary |
|---|---|
| public Dimension getMinimumSize() Overrides javax. Returns the minimum size for the
| |
| getModel | back to summary |
|---|---|
| public BoundedRangeModel getModel() Returns data model that handles the scrollbar's four fundamental properties: minimum, maximum, value, extent.
| |
| getOrientation | back to summary |
|---|---|
| public int getOrientation() Implements java. Returns the component's orientation (horizontal or vertical).
| |
| getUI | back to summary |
|---|---|
| public ScrollBarUI getUI() Overrides javax. Returns the delegate that implements the look and feel for this component.
| |
| getUIClassID | back to summary |
|---|---|
| public String getUIClassID() Overrides javax. Returns the name of the LookAndFeel class for this component.
| |
| getUnitIncrement | back to summary |
|---|---|
| public int getUnitIncrement(int direction) Returns the amount to change the scrollbar's value by, given a unit up/down request. A ScrollBarUI implementation typically calls this method when the user clicks on a scrollbar up/down arrow and uses the result to update the scrollbar's value. Subclasses may override this method to compute a value, e.g. the change required to scroll one (variable height) line of text or one row in a table. The JScrollPane component creates scrollbars (by default) that override this method and delegate to the viewports Scrollable view, if it has one. The Scrollable interface provides a more specialized version of this method. Some look and feel implementations that provide custom scrolling behavior ignore this property.
| |
| getUnitIncrement | back to summary |
|---|---|
| public int getUnitIncrement() Implements java. For backwards compatibility with java.awt.Scrollbar. | |
| getValue | back to summary |
|---|---|
| public int getValue() Implements java. Returns the scrollbar's value.
| |
| getValueIsAdjusting | back to summary |
|---|---|
| public boolean getValueIsAdjusting() True if the scrollbar knob is being dragged.
| |
| getVisibleAmount | back to summary |
|---|---|
| public int getVisibleAmount() Implements java. Returns the scrollbar's extent, aka its "visibleAmount". In many scrollbar look and feel implementations the size of the scrollbar "knob" or "thumb" is proportional to the extent.
| |
| paramString | back to summary |
|---|---|
| protected String paramString() Overrides javax. Returns a string representation of this JScrollBar. This method
is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not
be
| |
| removeAdjustmentListener | back to summary |
|---|---|
| public void removeAdjustmentListener(AdjustmentListener l) Implements java. Removes an AdjustmentEvent listener.
| |
| setBlockIncrement | back to summary |
|---|---|
| public void setBlockIncrement(int blockIncrement) Implements java. Sets the blockIncrement property. Note, that if the argument is equal to the value of Integer.MIN_VALUE, then most look and feel implementations will not provide scrolling to the right/down. Some look and feel implementations that provide custom scrolling behavior ignore this property.
| |
| setEnabled | back to summary |
|---|---|
| public void setEnabled(boolean x) Overrides javax. Enables the component so that the knob position can be changed. When the disabled, the knob position cannot be changed.
| |
| setMaximum | back to summary |
|---|---|
| public void setMaximum(int maximum) Implements java. Sets the model's maximum property. Note that the scrollbar's value can only be set to maximum - extent.
| |
| setMaximumSize | back to summary |
|---|---|
| public void setMaximumSize(Dimension maximumSize) Overrides javax. Unlike most components,
| |
| setMinimum | back to summary |
|---|---|
| public void setMinimum(int minimum) Implements java. Sets the model's minimum property.
| |
| setMinimumSize | back to summary |
|---|---|
| public void setMinimumSize(Dimension minimumSize) Overrides javax. Unlike most components,
| |
| setModel | back to summary |
|---|---|
| public void setModel(BoundedRangeModel newModel) Sets the model that handles the scrollbar's four fundamental properties: minimum, maximum, value, extent.
| |
| setOrientation | back to summary |
|---|---|
| public void setOrientation(int orientation) Set the scrollbar's orientation to either VERTICAL or HORIZONTAL.
| |
| setUI | back to summary |
|---|---|
| public void setUI(ScrollBarUI ui) Sets the L&F object that renders this component.
| |
| setUnitIncrement | back to summary |
|---|---|
| public void setUnitIncrement(int unitIncrement) Implements java. Sets the unitIncrement property. Note, that if the argument is equal to the value of Integer.MIN_VALUE, then most look and feel implementations will not provide scrolling to the right/down. Some look and feel implementations that provide custom scrolling behavior ignore this property.
| |
| setValue | back to summary |
|---|---|
| public void setValue(int value) Implements java. Sets the scrollbar's value. This method just forwards the value to the model.
| |
| setValueIsAdjusting | back to summary |
|---|---|
| public void setValueIsAdjusting(boolean b) Sets the model's valueIsAdjusting property. Scrollbar look and feel implementations should set this property to true when a knob drag begins, and to false when the drag ends. The scrollbar model will not generate ChangeEvents while valueIsAdjusting is true.
| |
| setValues | back to summary |
|---|---|
| public void setValues(int newValue, int newExtent, int newMin, int newMax) Sets the four BoundedRangeModel properties after forcing the arguments to obey the usual constraints: minimum ≤ value ≤ value+extent ≤ maximum
| |
| setVisibleAmount | back to summary |
|---|---|
| public void setVisibleAmount(int extent) Implements java. Set the model's extent property.
| |
| updateUI | back to summary |
|---|---|
| public void updateUI() Overrides javax. Overrides
| |
| writeObject | back to summary |
|---|---|
| private void writeObject(ObjectOutputStream s) throws IOException Hides javax. See readObject() and writeObject() in JComponent for more information about serialization in Swing.
| |
JScrollBar class. It provides an implementation of the
Java Accessibility API appropriate to scroll bar user-interface
elements.Warning
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans package.
Please see java..
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public AccessibleRole | Returns: an instance of AccessibleRole describing the role of the objectOverrides javax. Get the role of this object. |
| public AccessibleStateSet | Returns: an instance of AccessibleState containing the current state of the objectOverrides javax. Get the state set of this object. |
| public AccessibleValue | Returns: this objectOverrides javax. Get the AccessibleValue associated with this object. |
| public Number | Returns: The current value of this object.Implements javax. Get the accessible value of this object. |
| public Number | Returns: The maximum value of this object.Implements javax. Get the maximum accessible value of this object. |
| public Number | Returns: The minimum value of this object.Implements javax. Get the minimum accessible value of this object. |
| public boolean | Returns: True if the value was set.Implements javax. Set the value of this object as a Number. |
| AccessibleJScrollBar | back to summary |
|---|---|
| protected AccessibleJScrollBar() Constructs an | |
| getAccessibleRole | back to summary |
|---|---|
| public AccessibleRole getAccessibleRole() Overrides javax. Get the role of this object.
| |
| getAccessibleStateSet | back to summary |
|---|---|
| public AccessibleStateSet getAccessibleStateSet() Overrides javax. Get the state set of this object.
| |
| getAccessibleValue | back to summary |
|---|---|
| public AccessibleValue getAccessibleValue() Overrides javax. Get the AccessibleValue associated with this object. In the implementation of the Java Accessibility API for this class, return this object, which is responsible for implementing the AccessibleValue interface on behalf of itself.
| |
| getCurrentAccessibleValue | back to summary |
|---|---|
| public Number getCurrentAccessibleValue() Implements javax. Get the accessible value of this object.
| |
| getMaximumAccessibleValue | back to summary |
|---|---|
| public Number getMaximumAccessibleValue() Implements javax. Get the maximum accessible value of this object.
| |
| getMinimumAccessibleValue | back to summary |
|---|---|
| public Number getMinimumAccessibleValue() Implements javax. Get the minimum accessible value of this object.
| |
| setCurrentAccessibleValue | back to summary |
|---|---|
| public boolean setCurrentAccessibleValue(Number n) Implements javax. Set the value of this object as a Number.
| |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | stateChanged(ChangeEvent e)
Implements javax. Invoked when the target of the listener has changed its state. |
| ModelListener | back to summary |
|---|---|
| private ModelListener() | |
| stateChanged | back to summary |
|---|---|
| public void stateChanged(ChangeEvent e) Implements javax. Doc from javax. Invoked when the target of the listener has changed its state. | |