APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing

public Class JScrollBar

extends JComponent
implements Adjustable, Accessible
Class Inheritance
All Implemented Interfaces
javax.accessibility.Accessible, java.awt.Adjustable
Known Direct Subclasses
javax.swing.JScrollPane.ScrollBar
Annotations
@JavaBean
defaultProperty:UI
description:A component that helps determine the visible content range of an area.
@SwingContainer:false
@SuppressWarnings:serial
Imports
java.awt.Adjustable, .Component, .Dimension, java.awt.event.AdjustmentEvent, .AdjustmentListener, java.beans.BeanProperty, .JavaBean, java.io.IOException, .ObjectOutputStream, .Serial, .Serializable, javax.accessibility.Accessible, .AccessibleContext, .AccessibleRole, .AccessibleState, .AccessibleStateSet, .AccessibleValue, javax.swing.event.ChangeEvent, .ChangeListener, .EventListenerList, javax.swing.plaf.ScrollBarUI

An implementation of a scrollbar. The user positions the knob in the scrollbar to determine the contents of the viewing area. The program typically adjusts the display so that the end of the scrollbar represents the end of the displayable contents, or 100% of the contents. The start of the scrollbar is the beginning of the displayable contents, or 0%. The position of the knob within those bounds then translates to the corresponding percentage of the displayable contents.

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.beans.XMLEncoder.

Author
David Kloba
Since
1.2
See Also
JScrollPane

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
JScrollBar.AccessibleJScrollBar

This class implements accessibility support for the JScrollBar class.

private class
JScrollBar.ModelListener

This class listens to ChangeEvents on the model and forwards AdjustmentEvents for the sake of backwards compatibility.

Field Summary

Modifier and TypeField 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.

Inherited from javax.swing.JComponent:
DEBUG_GRAPHICS_LOADEDfocusControllerivSourceComponentlistenerListpaintingChildTOOL_TIP_TEXT_KEYuiUNDEFINED_CONDITIONWHEN_ANCESTOR_OF_FOCUSED_COMPONENTWHEN_FOCUSEDWHEN_IN_FOCUSED_WINDOW

Constructor Summary

AccessConstructor and Description
public
JScrollBar(int
an orientation of the JScrollBar
orientation
,
int
an 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 JScrollBar
orientation
)

Creates 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

Method Summary

Modifier and TypeMethod and Description
public void
addAdjustmentListener(AdjustmentListener
the AdjustmentLister to add
l
)

Implements java.awt.Adjustable.addAdjustmentListener.

Adds an AdjustmentListener.

private void
checkOrientation(int orientation)

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 JScrollBar
getAccessibleContext
()

Overrides java.awt.Component.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this JScrollBar.

public AdjustmentListener[]

Returns:

all of the AdjustmentListeners added or an empty array if no listeners have been added
getAdjustmentListeners
()

Returns an array of all the AdjustmentListeners added to this JScrollBar with addAdjustmentListener().

public int

Returns:

the value of the blockIncrement property
getBlockIncrement
(int
is -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.awt.Adjustable.getBlockIncrement.

For backwards compatibility with java.awt.Scrollbar.

public int

Returns:

the value of the model's maximum property
getMaximum
()

Implements java.awt.Adjustable.getMaximum.

The maximum value of the scrollbar is maximum - extent.

public Dimension

Returns:

the maximum size as specified above
getMaximumSize
()

Overrides javax.swing.JComponent.getMaximumSize.

Returns the maximum size for the JScrollBar.

public int

Returns:

the value of the model's minimum property
getMinimum
()

Implements java.awt.Adjustable.getMinimum.

Returns the minimum value supported by the scrollbar (usually zero).

public Dimension

Returns:

the minimum size as specified above
getMinimumSize
()

Overrides javax.swing.JComponent.getMinimumSize.

Returns the minimum size for the JScrollBar.

public BoundedRangeModel

Returns:

the data model
getModel
()

Returns data model that handles the scrollbar's four fundamental properties: minimum, maximum, value, extent.

public int

Returns:

VERTICAL or HORIZONTAL
getOrientation
()

Implements java.awt.Adjustable.getOrientation.

Returns the component's orientation (horizontal or vertical).

public ScrollBarUI

Returns:

the scroll bar's current UI.
getUI
()

Overrides javax.swing.JComponent.getUI.

Returns the delegate that implements the look and feel for this component.

public String

Returns:

the string "ScrollBarUI"
getUIClassID
()

Overrides javax.swing.JComponent.getUIClassID.

Returns the name of the LookAndFeel class for this component.

public int

Returns:

the value of the unitIncrement property
getUnitIncrement
(int
is -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.awt.Adjustable.getUnitIncrement.

For backwards compatibility with java.awt.Scrollbar.

public int

Returns:

the model's value property
getValue
()

Implements java.awt.Adjustable.getValue.

Returns the scrollbar's value.

public boolean

Returns:

the value of the model's valueIsAdjusting property
getValueIsAdjusting
()

True if the scrollbar knob is being dragged.

public int

Returns:

the value of the model's extent property
getVisibleAmount
()

Implements java.awt.Adjustable.getVisibleAmount.

Returns the scrollbar's extent, aka its "visibleAmount".

protected String

Returns:

a string representation of this JScrollBar.
paramString
()

Overrides javax.swing.JComponent.paramString.

Returns a string representation of this JScrollBar.

public void
removeAdjustmentListener(AdjustmentListener
the AdjustmentLister to remove
l
)

Implements java.awt.Adjustable.removeAdjustmentListener.

Removes an AdjustmentEvent listener.

public void
setBlockIncrement(int blockIncrement)

Implements java.awt.Adjustable.setBlockIncrement.

Sets the blockIncrement property.

public void
setEnabled(boolean
a boolean value, where true enables the component and false disables it
x
)

Overrides javax.swing.JComponent.setEnabled.

Enables the component so that the knob position can be changed.

public void
setMaximum(int maximum)

Implements java.awt.Adjustable.setMaximum.

Sets the model's maximum property.

public void
setMaximumSize(Dimension
the desired maximum allowable size
maximumSize
)

Overrides javax.swing.JComponent.setMaximumSize.

Unlike most components, JScrollBar derives the maximum size from the preferred size in one axis and a fixed maximum size in the other.

public void
setMinimum(int minimum)

Implements java.awt.Adjustable.setMinimum.

Sets the model's minimum property.

public void
setMinimumSize(Dimension
the new minimum size of this component
minimumSize
)

Overrides javax.swing.JComponent.setMinimumSize.

Unlike most components, JScrollBar derives the minimum size from the preferred size in one axis and a fixed minimum size in the other.

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 JScrollBar
orientation
)

Set the scrollbar's orientation to either VERTICAL or HORIZONTAL.

public void
setUI(ScrollBarUI
the ScrollBarUI L&F object
ui
)

Sets the L&F; object that renders this component.

public void
setUnitIncrement(int unitIncrement)

Implements java.awt.Adjustable.setUnitIncrement.

Sets the unitIncrement property.

public void
setValue(int value)

Implements java.awt.Adjustable.setValue.

Sets the scrollbar's value.

public void
setValueIsAdjusting(boolean
true if the upcoming changes to the value property are part of a series
b
)

Sets 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.awt.Adjustable.setVisibleAmount.

Set the model's extent property.

public void
updateUI()

Overrides javax.swing.JComponent.updateUI.

Overrides JComponent.updateUI.

private void
writeObject(ObjectOutputStream s)

Hides javax.swing.JComponent.writeObject.

See readObject() and writeObject() in JComponent for more information about serialization in Swing.

Inherited from javax.swing.JComponent:
_paintImmediatelyaddAncestorListeneraddNotifyaddVetoableChangeListeneralwaysOnTopcheckIfChildObscuredBySiblingclientPropertyChangedcomponentInputMapChangedcomputeVisibleRectcomputeVisibleRectcompWriteObjectNotifycontainscreateToolTipdisabledndDonedropLocationForPointenablefirePropertyChangefirePropertyChangefirePropertyChangefireVetoableChangegetActionForKeyStrokegetActionMapgetActionMapgetAlignmentXgetAlignmentYgetAncestorListenersgetAutoscrollsgetBaselinegetBaselineResizeBehaviorgetBordergetBoundsgetClientPropertygetComponentGraphicsgetComponentPopupMenugetConditionForKeyStrokegetCreatedDoubleBuffergetDebugGraphicsOptionsgetDefaultLocalegetFontMetricsgetGraphicsgetGraphicsInvokedgetHeightgetInheritsPopupMenugetInputMapgetInputMapgetInputMapgetInputVerifiergetInsetsgetInsetsgetListenersgetLocationgetManagingFocusBackwardTraversalKeysgetManagingFocusForwardTraversalKeysgetNextFocusableComponentgetPopupLocationgetPreferredSizegetRegisteredKeyStrokesgetRootPanegetSizegetToolTipLocationgetToolTipTextgetToolTipTextgetTopLevelAncestorgetTransferHandlergetVerifyInputWhenFocusTargetgetVetoableChangeListenersgetVisibleRectgetWidthgetWriteObjCountergetXgetYgrabFocushideisDoubleBufferedisLightweightComponentisManagingFocusisOpaqueisOptimizedDrawingEnabledisPaintingisPaintingForPrintisPaintingOriginisPaintingTileisRequestFocusEnabledisValidateRootpaintpaintBorderpaintChildrenpaintComponentpaintForceDoubleBufferedpaintImmediatelypaintImmediatelypaintToOffscreenprintprintAllprintBorderprintChildrenprintComponentprocessComponentKeyEventprocessKeyBindingprocessKeyBindingsprocessKeyBindingsForAllComponentsprocessKeyEventprocessMouseEventprocessMouseMotionEventputClientPropertyrectangleIsObscuredregisterKeyboardActionregisterKeyboardActionremoveAncestorListenerremoveNotifyremoveVetoableChangeListenerrepaintrepaintrequestDefaultFocusrequestFocusrequestFocusrequestFocusInWindowrequestFocusInWindowresetKeyboardActionsreshaperevalidatesafelyGetGraphicssafelyGetGraphicsscrollRectToVisiblesetActionMapsetAlignmentXsetAlignmentYsetAutoscrollssetBackgroundsetBordersetComponentPopupMenusetCreatedDoubleBuffersetDebugGraphicsOptionssetDefaultLocalesetDoubleBufferedsetDropLocationsetFocusTraversalKeyssetFontsetForegroundsetInheritsPopupMenusetInputMapsetInputVerifiersetNextFocusableComponentsetOpaquesetPaintingChildsetPreferredSizesetRequestFocusEnabledsetToolTipTextsetTransferHandlersetUIsetUIPropertysetVerifyInputWhenFocusTargetsetVisiblesetWriteObjCountershouldDebugGraphicssuperProcessMouseMotionEventunregisterKeyboardActionupdate

Field Detail

blockIncrementback 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.

See Also
setBlockIncrement
fwdAdjustmentEventsback to summary
private ChangeListener fwdAdjustmentEvents

All changes from the model are treated as though the user moved the scrollbar knob.

modelback to summary
protected BoundedRangeModel model

The model that represents the scrollbar's minimum, maximum, extent (aka "visibleAmount") and current value.

See Also
setModel
orientationback to summary
protected int orientation

Orientation of this scrollBar.

See Also
setOrientation
uiClassIDback to summary
private static final String uiClassID

Hides javax.swing.JComponent.uiClassID.

See Also
getUIClassID, readObject
unitIncrementback to summary
protected int unitIncrement

Stores the amount by which the value of the scrollbar is changed upon a unit up/down request.

See Also
setUnitIncrement

Constructor Detail

JScrollBarback 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 setBlockIncrement to set the block increment to a size slightly smaller than the view's extent. That way, when the user jumps the knob to an adjacent position, one or two lines of the original contents remain in view.

Parameters
orientation:int

an orientation of the JScrollBar

value:int

an int giving the current value

extent:int

an int giving the amount by which the value can "jump"

min:int

an int giving the minimum value

max:int

an int giving the maximum value

Exceptions
IllegalArgumentException:
if orientation is not one of VERTICAL, HORIZONTAL
See Also
setOrientation, setValue, setVisibleAmount, setMinimum, setMaximum
JScrollBarback 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
Parameters
orientation:int

an orientation of the JScrollBar

JScrollBarback to summary
public JScrollBar()

Creates a vertical scrollbar with the following initial values:

minimum = 0
maximum = 100
value = 0
extent = 10

Method Detail

addAdjustmentListenerback to summary
public void addAdjustmentListener(AdjustmentListener l)

Implements java.awt.Adjustable.addAdjustmentListener.

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.

Parameters
l:AdjustmentListener

the AdjustmentLister to add

See Also
removeAdjustmentListener, BoundedRangeModel#addChangeListener
checkOrientationback to summary
private void checkOrientation(int orientation)
fireAdjustmentValueChangedback to summary
protected void fireAdjustmentValueChanged(int id, int type, int value)

Notify listeners that the scrollbar's model has changed.

Parameters
id:int

an integer indicating the type of event.

type:int

an integer indicating the adjustment type.

value:int

the current value of the adjustment

See Also
addAdjustmentListener, EventListenerList
fireAdjustmentValueChangedback to summary
private void fireAdjustmentValueChanged(int id, int type, int value, boolean isAdjusting)

Notify listeners that the scrollbar's model has changed.

See Also
addAdjustmentListener, EventListenerList
getAccessibleContextback to summary
public AccessibleContext getAccessibleContext()

Overrides java.awt.Component.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

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.

Returns:AccessibleContext

an AccessibleJScrollBar that serves as the AccessibleContext of this JScrollBar

Annotations
@BeanProperty
bound:false
getAdjustmentListenersback to summary
public AdjustmentListener[] getAdjustmentListeners()

Returns an array of all the AdjustmentListeners added to this JScrollBar with addAdjustmentListener().

Returns:AdjustmentListener[]

all of the AdjustmentListeners added or an empty array if no listeners have been added

Annotations
@BeanProperty
bound:false
Since
1.4
getBlockIncrementback 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.

Parameters
direction:int

is -1 or 1 for up/down respectively

Returns:int

the value of the blockIncrement property

See Also
setBlockIncrement, setValue, Scrollable#getScrollableBlockIncrement
getBlockIncrementback to summary
public int getBlockIncrement()

Implements java.awt.Adjustable.getBlockIncrement.

For backwards compatibility with java.awt.Scrollbar.

See Also
Adjustable#getBlockIncrement, getBlockIncrement(int)
getMaximumback to summary
public int getMaximum()

Implements java.awt.Adjustable.getMaximum.

The maximum value of the scrollbar is maximum - extent.

Returns:int

the value of the model's maximum property

See Also
setMaximum
getMaximumSizeback to summary
public Dimension getMaximumSize()

Overrides javax.swing.JComponent.getMaximumSize.

Returns the maximum size for the JScrollBar. The scrollbar is flexible along its scrolling axis and rigid along the other axis. As specified in setMaximumSize JScrollBar will derive the maximum size from the preferred size in one axis and a fixed maximum size in the other.

Returns:Dimension

the maximum size as specified above

getMinimumback to summary
public int getMinimum()

Implements java.awt.Adjustable.getMinimum.

Returns the minimum value supported by the scrollbar (usually zero).

Returns:int

the value of the model's minimum property

See Also
setMinimum
getMinimumSizeback to summary
public Dimension getMinimumSize()

Overrides javax.swing.JComponent.getMinimumSize.

Returns the minimum size for the JScrollBar. The scrollbar is flexible along its scrolling axis and rigid along the other axis. As specified in setMinimumSize JScrollBar will derive the minimum size from the preferred size in one axis and a fixed minimum size in the other.

Returns:Dimension

the minimum size as specified above

getModelback to summary
public BoundedRangeModel getModel()

Returns data model that handles the scrollbar's four fundamental properties: minimum, maximum, value, extent.

Returns:BoundedRangeModel

the data model

See Also
setModel
getOrientationback to summary
public int getOrientation()

Implements java.awt.Adjustable.getOrientation.

Returns the component's orientation (horizontal or vertical).

Returns:int

VERTICAL or HORIZONTAL

See Also
setOrientation, java.awt.Adjustable#getOrientation
getUIback to summary
public ScrollBarUI getUI()

Overrides javax.swing.JComponent.getUI.

Returns the delegate that implements the look and feel for this component.

Returns:ScrollBarUI

the scroll bar's current UI.

See Also
JComponent#setUI
getUIClassIDback to summary
public String getUIClassID()

Overrides javax.swing.JComponent.getUIClassID.

Returns the name of the LookAndFeel class for this component.

Returns:String

the string "ScrollBarUI"

Annotations
@BeanProperty
bound:false
See Also
JComponent#getUIClassID, UIDefaults#getUI
getUnitIncrementback 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.

Parameters
direction:int

is -1 or 1 for up/down respectively

Returns:int

the value of the unitIncrement property

See Also
setUnitIncrement, setValue, Scrollable#getScrollableUnitIncrement
getUnitIncrementback to summary
public int getUnitIncrement()

Implements java.awt.Adjustable.getUnitIncrement.

For backwards compatibility with java.awt.Scrollbar.

See Also
Adjustable#getUnitIncrement, getUnitIncrement(int)
getValueback to summary
public int getValue()

Implements java.awt.Adjustable.getValue.

Returns the scrollbar's value.

Returns:int

the model's value property

See Also
setValue
getValueIsAdjustingback to summary
public boolean getValueIsAdjusting()

True if the scrollbar knob is being dragged.

Returns:boolean

the value of the model's valueIsAdjusting property

See Also
setValueIsAdjusting
getVisibleAmountback to summary
public int getVisibleAmount()

Implements java.awt.Adjustable.getVisibleAmount.

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.

Returns:int

the value of the model's extent property

See Also
setVisibleAmount
paramStringback to summary
protected String paramString()

Overrides javax.swing.JComponent.paramString.

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 null.

Returns:String

a string representation of this JScrollBar.

removeAdjustmentListenerback to summary
public void removeAdjustmentListener(AdjustmentListener l)

Implements java.awt.Adjustable.removeAdjustmentListener.

Removes an AdjustmentEvent listener.

Parameters
l:AdjustmentListener

the AdjustmentLister to remove

See Also
addAdjustmentListener
setBlockIncrementback to summary
public void setBlockIncrement(int blockIncrement)

Implements java.awt.Adjustable.setBlockIncrement.

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.

Annotations
@BeanProperty
preferred:true
description:The scrollbar\'s block increment.
See Also
getBlockIncrement()
setEnabledback to summary
public void setEnabled(boolean x)

Overrides javax.swing.JComponent.setEnabled.

Enables the component so that the knob position can be changed. When the disabled, the knob position cannot be changed.

Parameters
x:boolean

a boolean value, where true enables the component and false disables it

setMaximumback to summary
public void setMaximum(int maximum)

Implements java.awt.Adjustable.setMaximum.

Sets the model's maximum property. Note that the scrollbar's value can only be set to maximum - extent.

Annotations
@BeanProperty
bound:false
preferred:true
description:The scrollbar\'s maximum value.
See Also
getMaximum, BoundedRangeModel#setMaximum
setMaximumSizeback to summary
public void setMaximumSize(Dimension maximumSize)

Overrides javax.swing.JComponent.setMaximumSize.

Unlike most components, JScrollBar derives the maximum size from the preferred size in one axis and a fixed maximum size in the other. Thus, it overrides JComponent.setMaximumSize contract that subsequent calls to getMaximumSize will return the same value as set in JComponent.setMaximumSize.

Parameters
maximumSize:Dimension

the desired maximum allowable size

setMinimumback to summary
public void setMinimum(int minimum)

Implements java.awt.Adjustable.setMinimum.

Sets the model's minimum property.

Annotations
@BeanProperty
bound:false
preferred:true
description:The scrollbar\'s minimum value.
See Also
getMinimum, BoundedRangeModel#setMinimum
setMinimumSizeback to summary
public void setMinimumSize(Dimension minimumSize)

Overrides javax.swing.JComponent.setMinimumSize.

Unlike most components, JScrollBar derives the minimum size from the preferred size in one axis and a fixed minimum size in the other. Thus, it overrides JComponent.setMinimumSize contract that subsequent calls to getMinimumSize will return the same value as set in JComponent.setMinimumSize.

Parameters
minimumSize:Dimension

the new minimum size of this component

setModelback to summary
public void setModel(BoundedRangeModel newModel)

Sets the model that handles the scrollbar's four fundamental properties: minimum, maximum, value, extent.

Parameters
newModel:BoundedRangeModel

a new model

Annotations
@BeanProperty
expert:true
description:The scrollbar\'s BoundedRangeModel.
See Also
getModel
setOrientationback to summary
public void setOrientation(int orientation)

Set the scrollbar's orientation to either VERTICAL or HORIZONTAL.

Parameters
orientation:int

an orientation of the JScrollBar

Annotations
@BeanProperty
preferred:true
visualUpdate:true
enumerationValues:JScrollBar.VERTICAL, JScrollBar.HORIZONTAL
description:The scrollbar\'s orientation.
Exceptions
IllegalArgumentException:
if orientation is not one of VERTICAL, HORIZONTAL
See Also
getOrientation
setUIback to summary
public void setUI(ScrollBarUI ui)

Sets the L&F object that renders this component.

Parameters
ui:ScrollBarUI

the ScrollBarUI L&F object

Annotations
@BeanProperty
hidden:true
visualUpdate:true
description:The UI object that implements the Component\'s LookAndFeel
Since
1.4
See Also
UIDefaults#getUI
setUnitIncrementback to summary
public void setUnitIncrement(int unitIncrement)

Implements java.awt.Adjustable.setUnitIncrement.

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.

Annotations
@BeanProperty
preferred:true
description:The scrollbar\'s unit increment.
See Also
getUnitIncrement
setValueback to summary
public void setValue(int value)

Implements java.awt.Adjustable.setValue.

Sets the scrollbar's value. This method just forwards the value to the model.

Annotations
@BeanProperty
bound:false
preferred:true
description:The scrollbar\'s current value.
See Also
getValue, BoundedRangeModel#setValue
setValueIsAdjustingback 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.

Parameters
b:boolean

true if the upcoming changes to the value property are part of a series

Annotations
@BeanProperty
bound:false
expert:true
description:True if the scrollbar thumb is being dragged.
See Also
getValueIsAdjusting, BoundedRangeModel#setValueIsAdjusting
setValuesback 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
Parameters
newValue:int

an int giving the current value

newExtent:int

an int giving the amount by which the value can "jump"

newMin:int

an int giving the minimum value

newMax:int

an int giving the maximum value

See Also
BoundedRangeModel#setRangeProperties, setValue, setVisibleAmount, setMinimum, setMaximum
setVisibleAmountback to summary
public void setVisibleAmount(int extent)

Implements java.awt.Adjustable.setVisibleAmount.

Set the model's extent property.

Annotations
@BeanProperty
bound:false
preferred:true
description:The amount of the view that is currently visible.
See Also
getVisibleAmount, BoundedRangeModel#setExtent
updateUIback to summary
public void updateUI()

Overrides javax.swing.JComponent.updateUI.

Overrides JComponent.updateUI.

See Also
JComponent#updateUI
writeObjectback to summary
private void writeObject(ObjectOutputStream s) throws IOException

Hides javax.swing.JComponent.writeObject.

See readObject() and writeObject() in JComponent for more information about serialization in Swing.

Annotations
@Serial
Exceptions
IOException:

Doc from java.awt.Container.writeObject.

if an I/O error occurs

javax.swing back to summary

protected Class JScrollBar.AccessibleJScrollBar

extends AccessibleJComponent
implements AccessibleValue
Class Inheritance
All Implemented Interfaces
javax.accessibility.AccessibleValue
Annotations
@SuppressWarnings:serial

This class implements accessibility support for the 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.beans.XMLEncoder.

Field Summary

Inherited from javax.swing.JComponent.AccessibleJComponent:
accessibleFocusHandler

Constructor Summary

AccessConstructor and Description
protected
AccessibleJScrollBar()

Constructs an AccessibleJScrollBar.

Method Summary

Modifier and TypeMethod and Description
public AccessibleRole

Returns:

an instance of AccessibleRole describing the role of the object
getAccessibleRole
()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleRole.

Get the role of this object.

public AccessibleStateSet

Returns:

an instance of AccessibleState containing the current state of the object
getAccessibleStateSet
()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleStateSet.

Get the state set of this object.

public AccessibleValue

Returns:

this object
getAccessibleValue
()

Overrides javax.accessibility.AccessibleContext.getAccessibleValue.

Get the AccessibleValue associated with this object.

public Number

Returns:

The current value of this object.
getCurrentAccessibleValue
()

Implements javax.accessibility.AccessibleValue.getCurrentAccessibleValue.

Get the accessible value of this object.

public Number

Returns:

The maximum value of this object.
getMaximumAccessibleValue
()

Implements javax.accessibility.AccessibleValue.getMaximumAccessibleValue.

Get the maximum accessible value of this object.

public Number

Returns:

The minimum value of this object.
getMinimumAccessibleValue
()

Implements javax.accessibility.AccessibleValue.getMinimumAccessibleValue.

Get the minimum accessible value of this object.

public boolean

Returns:

True if the value was set.
setCurrentAccessibleValue
(Number n)

Implements javax.accessibility.AccessibleValue.setCurrentAccessibleValue.

Set the value of this object as a Number.

Inherited from javax.swing.JComponent.AccessibleJComponent:
addPropertyChangeListenergetAccessibleChildgetAccessibleChildrenCountgetAccessibleDescriptiongetAccessibleExtendedComponentgetAccessibleKeyBindinggetAccessibleNamegetBorderTitlegetTitledBorderTextgetToolTipTextremovePropertyChangeListener

Constructor Detail

AccessibleJScrollBarback to summary
protected AccessibleJScrollBar()

Constructs an AccessibleJScrollBar.

Method Detail

getAccessibleRoleback to summary
public AccessibleRole getAccessibleRole()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleRole.

Get the role of this object.

Returns:AccessibleRole

an instance of AccessibleRole describing the role of the object

getAccessibleStateSetback to summary
public AccessibleStateSet getAccessibleStateSet()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleStateSet.

Get the state set of this object.

Returns:AccessibleStateSet

an instance of AccessibleState containing the current state of the object

See Also
AccessibleState
getAccessibleValueback to summary
public AccessibleValue getAccessibleValue()

Overrides javax.accessibility.AccessibleContext.getAccessibleValue.

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.

Returns:AccessibleValue

this object

getCurrentAccessibleValueback to summary
public Number getCurrentAccessibleValue()

Implements javax.accessibility.AccessibleValue.getCurrentAccessibleValue.

Get the accessible value of this object.

Returns:Number

The current value of this object.

getMaximumAccessibleValueback to summary
public Number getMaximumAccessibleValue()

Implements javax.accessibility.AccessibleValue.getMaximumAccessibleValue.

Get the maximum accessible value of this object.

Returns:Number

The maximum value of this object.

getMinimumAccessibleValueback to summary
public Number getMinimumAccessibleValue()

Implements javax.accessibility.AccessibleValue.getMinimumAccessibleValue.

Get the minimum accessible value of this object.

Returns:Number

The minimum value of this object.

setCurrentAccessibleValueback to summary
public boolean setCurrentAccessibleValue(Number n)

Implements javax.accessibility.AccessibleValue.setCurrentAccessibleValue.

Set the value of this object as a Number.

Returns:boolean

True if the value was set.

javax.swing back to summary

private Class JScrollBar.ModelListener

extends Object
implements ChangeListener, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, javax.swing.event.ChangeListener, java.util.EventListener

This class listens to ChangeEvents on the model and forwards AdjustmentEvents for the sake of backwards compatibility. Unfortunately there's no way to determine the proper type of the AdjustmentEvent as all updates to the model's value are considered equivalent.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
stateChanged(ChangeEvent e)

Implements javax.swing.event.ChangeListener.stateChanged.

Invoked when the target of the listener has changed its state.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ModelListenerback to summary
private ModelListener()

Method Detail

stateChangedback to summary
public void stateChanged(ChangeEvent e)

Implements javax.swing.event.ChangeListener.stateChanged.

Doc from javax.swing.event.ChangeListener.stateChanged.

Invoked when the target of the listener has changed its state.