- java.lang.Object
-
- java.awt.Component
-
- java.awt.Scrollbar
-
- All Implemented Interfaces:
- Adjustable, ImageObserver, MenuContainer, Serializable, Accessible
public class Scrollbar extends Component implements Adjustable, Accessible
TheScrollbar
class embodies a scroll bar, a familiar user-interface object. A scroll bar provides a convenient means for allowing a user to select from a range of values. The following three vertical scroll bars could be used as slider controls to pick the red, green, and blue components of a color:Each scroll bar in this example could be created with code similar to the following:
redSlider=new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, 255); add(redSlider);
Alternatively, a scroll bar can represent a range of values. For example, if a scroll bar is used for scrolling through text, the width of the "bubble" (also called the "thumb" or "scroll box") can be used to represent the amount of text that is visible. Here is an example of a scroll bar that represents a range:
The value range represented by the bubble in this example is the visible amount. The horizontal scroll bar in this example could be created with code like the following:
ranger = new Scrollbar(Scrollbar.HORIZONTAL, 0, 60, 0, 300); add(ranger);
Note that the actual maximum value of the scroll bar is the
maximum
minus thevisible amount
. In the previous example, because themaximum
is 300 and thevisible amount
is 60, the actual maximum value is 240. The range of the scrollbar track is 0 - 300. The left side of the bubble indicates the value of the scroll bar.Normally, the user changes the value of the scroll bar by making a gesture with the mouse. For example, the user can drag the scroll bar's bubble up and down, or click in the scroll bar's unit increment or block increment areas. Keyboard gestures can also be mapped to the scroll bar. By convention, the Page Up and Page Down keys are equivalent to clicking in the scroll bar's block increment and block decrement areas.
When the user changes the value of the scroll bar, the scroll bar receives an instance of
AdjustmentEvent
. The scroll bar processes this event, passing it along to any registered listeners.Any object that wishes to be notified of changes to the scroll bar's value should implement
AdjustmentListener
, an interface defined in the packagejava.awt.event
. Listeners can be added and removed dynamically by calling the methodsaddAdjustmentListener
andremoveAdjustmentListener
.The
AdjustmentEvent
class defines five types of adjustment event, listed here:AdjustmentEvent.TRACK
is sent out when the user drags the scroll bar's bubble.AdjustmentEvent.UNIT_INCREMENT
is sent out when the user clicks in the left arrow of a horizontal scroll bar, or the top arrow of a vertical scroll bar, or makes the equivalent gesture from the keyboard.AdjustmentEvent.UNIT_DECREMENT
is sent out when the user clicks in the right arrow of a horizontal scroll bar, or the bottom arrow of a vertical scroll bar, or makes the equivalent gesture from the keyboard.AdjustmentEvent.BLOCK_INCREMENT
is sent out when the user clicks in the track, to the left of the bubble on a horizontal scroll bar, or above the bubble on a vertical scroll bar. By convention, the Page Up key is equivalent, if the user is using a keyboard that defines a Page Up key.AdjustmentEvent.BLOCK_DECREMENT
is sent out when the user clicks in the track, to the right of the bubble on a horizontal scroll bar, or below the bubble on a vertical scroll bar. By convention, the Page Down key is equivalent, if the user is using a keyboard that defines a Page Down key.
The JDK 1.0 event system is supported for backwards compatibility, but its use with newer versions of the platform is discouraged. The five types of adjustment events introduced with JDK 1.1 correspond to the five event types that are associated with scroll bars in previous platform versions. The following list gives the adjustment event type, and the corresponding JDK 1.0 event type it replaces.
AdjustmentEvent.TRACK
replacesEvent.SCROLL_ABSOLUTE
AdjustmentEvent.UNIT_INCREMENT
replacesEvent.SCROLL_LINE_UP
AdjustmentEvent.UNIT_DECREMENT
replacesEvent.SCROLL_LINE_DOWN
AdjustmentEvent.BLOCK_INCREMENT
replacesEvent.SCROLL_PAGE_UP
AdjustmentEvent.BLOCK_DECREMENT
replacesEvent.SCROLL_PAGE_DOWN
Note: We recommend using a
Scrollbar
for value selection only. If you want to implement a scrollable component inside a container, we recommend you use aScrollPane
. If you use aScrollbar
for this purpose, you are likely to encounter issues with painting, key handling, sizing and positioning.- Since:
- JDK1.0
- See Also:
AdjustmentEvent
,AdjustmentListener
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description protected class
Scrollbar.AccessibleAWTScrollBar
This class implements accessibility support for theScrollbar
class.-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field and Description static int
HORIZONTAL
A constant that indicates a horizontal scroll bar.static int
VERTICAL
A constant that indicates a vertical scroll bar.-
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.Adjustable
NO_ORIENTATION
-
-
Constructor Summary
Constructors Constructor and Description Scrollbar()
Constructs a new vertical scroll bar.Scrollbar(int orientation)
Constructs a new scroll bar with the specified orientation.Scrollbar(int orientation, int value, int visible, int minimum, int maximum)
Constructs a new scroll bar with the specified orientation, initial value, visible amount, and minimum and maximum values.
-
Method Summary
Methods Modifier and Type Method and Description void
addAdjustmentListener(AdjustmentListener l)
Adds the specified adjustment listener to receive instances ofAdjustmentEvent
from this scroll bar.void
addNotify()
Creates theScrollbar
's peer.AccessibleContext
getAccessibleContext()
Gets theAccessibleContext
associated with thisScrollbar
.AdjustmentListener[]
getAdjustmentListeners()
Returns an array of all the adjustment listeners registered on this scrollbar.int
getBlockIncrement()
Gets the block increment of this scroll bar.int
getLineIncrement()
Deprecated.As of JDK version 1.1, replaced bygetUnitIncrement()
.<T extends EventListener>
T[]getListeners(Class<T> listenerType)
Returns an array of all the objects currently registered asFooListener
s upon thisScrollbar
.int
getMaximum()
Gets the maximum value of this scroll bar.int
getMinimum()
Gets the minimum value of this scroll bar.int
getOrientation()
Returns the orientation of this scroll bar.int
getPageIncrement()
Deprecated.As of JDK version 1.1, replaced bygetBlockIncrement()
.int
getUnitIncrement()
Gets the unit increment for this scrollbar.int
getValue()
Gets the current value of this scroll bar.boolean
getValueIsAdjusting()
Returns true if the value is in the process of changing as a result of actions being taken by the user.int
getVisible()
Deprecated.As of JDK version 1.1, replaced bygetVisibleAmount()
.int
getVisibleAmount()
Gets the visible amount of this scroll bar.protected String
paramString()
Returns a string representing the state of thisScrollbar
.protected void
processAdjustmentEvent(AdjustmentEvent e)
Processes adjustment events occurring on this scrollbar by dispatching them to any registeredAdjustmentListener
objects.protected void
processEvent(AWTEvent e)
Processes events on this scroll bar.void
removeAdjustmentListener(AdjustmentListener l)
Removes the specified adjustment listener so that it no longer receives instances ofAdjustmentEvent
from this scroll bar.void
setBlockIncrement(int v)
Sets the block increment for this scroll bar.void
setLineIncrement(int v)
Deprecated.As of JDK version 1.1, replaced bysetUnitIncrement(int)
.void
setMaximum(int newMaximum)
Sets the maximum value of this scroll bar.void
setMinimum(int newMinimum)
Sets the minimum value of this scroll bar.void
setOrientation(int orientation)
Sets the orientation for this scroll bar.void
setPageIncrement(int v)
Deprecated.As of JDK version 1.1, replaced bysetBlockIncrement()
.void
setUnitIncrement(int v)
Sets the unit increment for this scroll bar.void
setValue(int newValue)
Sets the value of this scroll bar to the specified value.void
setValueIsAdjusting(boolean b)
Sets thevalueIsAdjusting
property.void
setValues(int value, int visible, int minimum, int maximum)
Sets the values of four properties for this scroll bar:value
,visibleAmount
,minimum
, andmaximum
.void
setVisibleAmount(int newAmount)
Sets the visible amount of this scroll bar.-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
-
-
-
-
Field Detail
-
HORIZONTAL
public static final int HORIZONTAL
A constant that indicates a horizontal scroll bar.- See Also:
- Constant Field Values
-
VERTICAL
public static final int VERTICAL
A constant that indicates a vertical scroll bar.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Scrollbar
public Scrollbar() throws HeadlessException
Constructs a new vertical scroll bar. The default properties of the scroll bar are listed in the following table:Property Description Default Value orientation indicates whether the scroll bar is vertical
or horizontalScrollbar.VERTICAL
value value which controls the location
of the scroll bar's bubble0 visible amount visible amount of the scroll bar's range,
typically represented by the size of the
scroll bar's bubble10 minimum minimum value of the scroll bar 0 maximum maximum value of the scroll bar 100 unit increment amount the value changes when the
Line Up or Line Down key is pressed,
or when the end arrows of the scrollbar
are clicked1 block increment amount the value changes when the
Page Up or Page Down key is pressed,
or when the scrollbar track is clicked
on either side of the bubble10 - Throws:
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true.- See Also:
GraphicsEnvironment.isHeadless()
-
Scrollbar
public Scrollbar(int orientation) throws HeadlessException
Constructs a new scroll bar with the specified orientation.The
orientation
argument must take one of the two valuesScrollbar.HORIZONTAL
, orScrollbar.VERTICAL
, indicating a horizontal or vertical scroll bar, respectively.- Parameters:
orientation
- indicates the orientation of the scroll bar- Throws:
IllegalArgumentException
- when an illegal value for theorientation
argument is suppliedHeadlessException
- if GraphicsEnvironment.isHeadless() returns true.- See Also:
GraphicsEnvironment.isHeadless()
-
Scrollbar
public Scrollbar(int orientation, int value, int visible, int minimum, int maximum) throws HeadlessException
Constructs a new scroll bar with the specified orientation, initial value, visible amount, and minimum and maximum values.The
orientation
argument must take one of the two valuesScrollbar.HORIZONTAL
, orScrollbar.VERTICAL
, indicating a horizontal or vertical scroll bar, respectively.The parameters supplied to this constructor are subject to the constraints described in
setValues(int, int, int, int)
.- Parameters:
orientation
- indicates the orientation of the scroll bar.value
- the initial value of the scroll barvisible
- the visible amount of the scroll bar, typically represented by the size of the bubbleminimum
- the minimum value of the scroll barmaximum
- the maximum value of the scroll bar- Throws:
IllegalArgumentException
- when an illegal value for theorientation
argument is suppliedHeadlessException
- if GraphicsEnvironment.isHeadless() returns true.- See Also:
setValues(int, int, int, int)
,GraphicsEnvironment.isHeadless()
-
-
Method Detail
-
addNotify
public void addNotify()
Creates theScrollbar
's peer. The peer allows you to modify the appearance of theScrollbar
without changing any of its functionality.- Overrides:
addNotify
in classComponent
- See Also:
Component.isDisplayable()
,Component.removeNotify()
,Component.invalidate()
-
getOrientation
public int getOrientation()
Returns the orientation of this scroll bar.- Specified by:
getOrientation
in interfaceAdjustable
- Returns:
- the orientation of this scroll bar, either
Scrollbar.HORIZONTAL
orScrollbar.VERTICAL
- See Also:
setOrientation(int)
-
setOrientation
public void setOrientation(int orientation)
Sets the orientation for this scroll bar.- Parameters:
orientation
- the orientation of this scroll bar, eitherScrollbar.HORIZONTAL
orScrollbar.VERTICAL
- Throws:
IllegalArgumentException
- if the value supplied fororientation
is not a legal value- Since:
- JDK1.1
- See Also:
getOrientation()
-
getValue
public int getValue()
Gets the current value of this scroll bar.- Specified by:
getValue
in interfaceAdjustable
- Returns:
- the current value of this scroll bar
- See Also:
getMinimum()
,getMaximum()
-
setValue
public void setValue(int newValue)
Sets the value of this scroll bar to the specified value.If the value supplied is less than the current
minimum
or greater than the currentmaximum - visibleAmount
, then eitherminimum
ormaximum - visibleAmount
is substituted, as appropriate.Normally, a program should change a scroll bar's value only by calling
setValues
. ThesetValues
method simultaneously and synchronously sets the minimum, maximum, visible amount, and value properties of a scroll bar, so that they are mutually consistent.Calling this method does not fire an
AdjustmentEvent
.- Specified by:
setValue
in interfaceAdjustable
- Parameters:
newValue
- the new value of the scroll bar- See Also:
setValues(int, int, int, int)
,getValue()
,getMinimum()
,getMaximum()
-
getMinimum
public int getMinimum()
Gets the minimum value of this scroll bar.- Specified by:
getMinimum
in interfaceAdjustable
- Returns:
- the minimum value of this scroll bar
- See Also:
getValue()
,getMaximum()
-
setMinimum
public void setMinimum(int newMinimum)
Sets the minimum value of this scroll bar.When
setMinimum
is called, the minimum value is changed, and other values (including the maximum, the visible amount, and the current scroll bar value) are changed to be consistent with the new minimum.Normally, a program should change a scroll bar's minimum value only by calling
setValues
. ThesetValues
method simultaneously and synchronously sets the minimum, maximum, visible amount, and value properties of a scroll bar, so that they are mutually consistent.Note that setting the minimum value to
Integer.MAX_VALUE
will result in the new minimum value being set toInteger.MAX_VALUE - 1
.- Specified by:
setMinimum
in interfaceAdjustable
- Parameters:
newMinimum
- the new minimum value for this scroll bar- Since:
- JDK1.1
- See Also:
setValues(int, int, int, int)
,setMaximum(int)
-
getMaximum
public int getMaximum()
Gets the maximum value of this scroll bar.- Specified by:
getMaximum
in interfaceAdjustable
- Returns:
- the maximum value of this scroll bar
- See Also:
getValue()
,getMinimum()
-
setMaximum
public void setMaximum(int newMaximum)
Sets the maximum value of this scroll bar.When
setMaximum
is called, the maximum value is changed, and other values (including the minimum, the visible amount, and the current scroll bar value) are changed to be consistent with the new maximum.Normally, a program should change a scroll bar's maximum value only by calling
setValues
. ThesetValues
method simultaneously and synchronously sets the minimum, maximum, visible amount, and value properties of a scroll bar, so that they are mutually consistent.Note that setting the maximum value to
Integer.MIN_VALUE
will result in the new maximum value being set toInteger.MIN_VALUE + 1
.- Specified by:
setMaximum
in interfaceAdjustable
- Parameters:
newMaximum
- the new maximum value for this scroll bar- Since:
- JDK1.1
- See Also:
setValues(int, int, int, int)
,setMinimum(int)
-
getVisibleAmount
public int getVisibleAmount()
Gets the visible amount of this scroll bar.When a scroll bar is used to select a range of values, the visible amount is used to represent the range of values that are currently visible. The size of the scroll bar's bubble (also called a thumb or scroll box), usually gives a visual representation of the relationship of the visible amount to the range of the scroll bar. Note that depending on platform, the value of the visible amount property may not be visually indicated by the size of the bubble.
The scroll bar's bubble may not be displayed when it is not moveable (e.g. when it takes up the entire length of the scroll bar's track, or when the scroll bar is disabled). Whether the bubble is displayed or not will not affect the value returned by
getVisibleAmount
.- Specified by:
getVisibleAmount
in interfaceAdjustable
- Returns:
- the visible amount of this scroll bar
- Since:
- JDK1.1
- See Also:
setVisibleAmount(int)
-
getVisible
@Deprecated public int getVisible()
Deprecated. As of JDK version 1.1, replaced bygetVisibleAmount()
.
-
setVisibleAmount
public void setVisibleAmount(int newAmount)
Sets the visible amount of this scroll bar.When a scroll bar is used to select a range of values, the visible amount is used to represent the range of values that are currently visible. The size of the scroll bar's bubble (also called a thumb or scroll box), usually gives a visual representation of the relationship of the visible amount to the range of the scroll bar. Note that depending on platform, the value of the visible amount property may not be visually indicated by the size of the bubble.
The scroll bar's bubble may not be displayed when it is not moveable (e.g. when it takes up the entire length of the scroll bar's track, or when the scroll bar is disabled). Whether the bubble is displayed or not will not affect the value returned by
getVisibleAmount
.If the visible amount supplied is less than
one
or greater than the currentmaximum - minimum
, then eitherone
ormaximum - minimum
is substituted, as appropriate.Normally, a program should change a scroll bar's value only by calling
setValues
. ThesetValues
method simultaneously and synchronously sets the minimum, maximum, visible amount, and value properties of a scroll bar, so that they are mutually consistent.- Specified by:
setVisibleAmount
in interfaceAdjustable
- Parameters:
newAmount
- the new visible amount- Since:
- JDK1.1
- See Also:
getVisibleAmount()
,setValues(int, int, int, int)
-
setUnitIncrement
public void setUnitIncrement(int v)
Sets the unit increment for this scroll bar.The unit increment is the value that is added or subtracted when the user activates the unit increment area of the scroll bar, generally through a mouse or keyboard gesture that the scroll bar receives as an adjustment event. The unit increment must be greater than zero. Attepts to set the unit increment to a value lower than 1 will result in a value of 1 being set.
- Specified by:
setUnitIncrement
in interfaceAdjustable
- Parameters:
v
- the amount by which to increment or decrement the scroll bar's value- Since:
- JDK1.1
- See Also:
getUnitIncrement()
-
setLineIncrement
@Deprecated public void setLineIncrement(int v)
Deprecated. As of JDK version 1.1, replaced bysetUnitIncrement(int)
.
-
getUnitIncrement
public int getUnitIncrement()
Gets the unit increment for this scrollbar.The unit increment is the value that is added or subtracted when the user activates the unit increment area of the scroll bar, generally through a mouse or keyboard gesture that the scroll bar receives as an adjustment event. The unit increment must be greater than zero.
- Specified by:
getUnitIncrement
in interfaceAdjustable
- Returns:
- the unit increment of this scroll bar
- Since:
- JDK1.1
- See Also:
setUnitIncrement(int)
-
getLineIncrement
@Deprecated public int getLineIncrement()
Deprecated. As of JDK version 1.1, replaced bygetUnitIncrement()
.
-
setBlockIncrement
public void setBlockIncrement(int v)
Sets the block increment for this scroll bar.The block increment is the value that is added or subtracted when the user activates the block increment area of the scroll bar, generally through a mouse or keyboard gesture that the scroll bar receives as an adjustment event. The block increment must be greater than zero. Attepts to set the block increment to a value lower than 1 will result in a value of 1 being set.
- Specified by:
setBlockIncrement
in interfaceAdjustable
- Parameters:
v
- the amount by which to increment or decrement the scroll bar's value- Since:
- JDK1.1
- See Also:
getBlockIncrement()
-
setPageIncrement
@Deprecated public void setPageIncrement(int v)
Deprecated. As of JDK version 1.1, replaced bysetBlockIncrement()
.
-
getBlockIncrement
public int getBlockIncrement()
Gets the block increment of this scroll bar.The block increment is the value that is added or subtracted when the user activates the block increment area of the scroll bar, generally through a mouse or keyboard gesture that the scroll bar receives as an adjustment event. The block increment must be greater than zero.
- Specified by:
getBlockIncrement
in interfaceAdjustable
- Returns:
- the block increment of this scroll bar
- Since:
- JDK1.1
- See Also:
setBlockIncrement(int)
-
getPageIncrement
@Deprecated public int getPageIncrement()
Deprecated. As of JDK version 1.1, replaced bygetBlockIncrement()
.
-
setValues
public void setValues(int value, int visible, int minimum, int maximum)
Sets the values of four properties for this scroll bar:value
,visibleAmount
,minimum
, andmaximum
. If the values supplied for these properties are inconsistent or incorrect, they will be changed to ensure consistency.This method simultaneously and synchronously sets the values of four scroll bar properties, assuring that the values of these properties are mutually consistent. It enforces the following constraints:
maximum
must be greater thanminimum
,maximum - minimum
must not be greater thanInteger.MAX_VALUE
,visibleAmount
must be greater than zero.visibleAmount
must not be greater thanmaximum - minimum
,value
must not be less thanminimum
, andvalue
must not be greater thanmaximum - visibleAmount
Calling this method does not fire an
AdjustmentEvent
.- Parameters:
value
- is the position in the current windowvisible
- is the visible amount of the scroll barminimum
- is the minimum value of the scroll barmaximum
- is the maximum value of the scroll bar- See Also:
setMinimum(int)
,setMaximum(int)
,setVisibleAmount(int)
,setValue(int)
-
getValueIsAdjusting
public boolean getValueIsAdjusting()
Returns true if the value is in the process of changing as a result of actions being taken by the user.- Returns:
- the value of the
valueIsAdjusting
property - Since:
- 1.4
- See Also:
setValueIsAdjusting(boolean)
-
setValueIsAdjusting
public void setValueIsAdjusting(boolean b)
Sets thevalueIsAdjusting
property.- Parameters:
b
- new adjustment-in-progress status- Since:
- 1.4
- See Also:
getValueIsAdjusting()
-
addAdjustmentListener
public void addAdjustmentListener(AdjustmentListener l)
Adds the specified adjustment listener to receive instances ofAdjustmentEvent
from this scroll bar. If l isnull
, no exception is thrown and no action is performed.Refer to AWT Threading Issues for details on AWT's threading model.
- Specified by:
addAdjustmentListener
in interfaceAdjustable
- Parameters:
l
- the adjustment listener- Since:
- JDK1.1
- See Also:
removeAdjustmentListener(java.awt.event.AdjustmentListener)
,getAdjustmentListeners()
,AdjustmentEvent
,AdjustmentListener
-
removeAdjustmentListener
public void removeAdjustmentListener(AdjustmentListener l)
Removes the specified adjustment listener so that it no longer receives instances ofAdjustmentEvent
from this scroll bar. If l isnull
, no exception is thrown and no action is performed.Refer to AWT Threading Issues for details on AWT's threading model.
- Specified by:
removeAdjustmentListener
in interfaceAdjustable
- Parameters:
l
- the adjustment listener- Since:
- JDK1.1
- See Also:
addAdjustmentListener(java.awt.event.AdjustmentListener)
,getAdjustmentListeners()
,AdjustmentEvent
,AdjustmentListener
-
getAdjustmentListeners
public AdjustmentListener[] getAdjustmentListeners()
Returns an array of all the adjustment listeners registered on this scrollbar.- Returns:
- all of this scrollbar's
AdjustmentListener
s or an empty array if no adjustment listeners are currently registered - Since:
- 1.4
- See Also:
addAdjustmentListener(java.awt.event.AdjustmentListener)
,removeAdjustmentListener(java.awt.event.AdjustmentListener)
,AdjustmentEvent
,AdjustmentListener
-
getListeners
public <T extends EventListener> T[] getListeners(Class<T> listenerType)
Returns an array of all the objects currently registered asFooListener
s upon thisScrollbar
.FooListener
s are registered using theaddFooListener
method.You can specify the
listenerType
argument with a class literal, such asFooListener.class
. For example, you can query aScrollbar
c
for its mouse listeners with the following code:MouseListener[] mls = (MouseListener[])(c.getListeners(MouseListener.class));
If no such listeners exist, this method returns an empty array.- Overrides:
getListeners
in classComponent
- Parameters:
listenerType
- the type of listeners requested; this parameter should specify an interface that descends fromjava.util.EventListener
- Returns:
- an array of all objects registered as
FooListener
s on this component, or an empty array if no such listeners have been added - Throws:
ClassCastException
- iflistenerType
doesn't specify a class or interface that implementsjava.util.EventListener
- Since:
- 1.3
- See Also:
Component.getComponentListeners()
,Component.getFocusListeners()
,Component.getHierarchyListeners()
,Component.getHierarchyBoundsListeners()
,Component.getKeyListeners()
,Component.getMouseListeners()
,Component.getMouseMotionListeners()
,Component.getMouseWheelListeners()
,Component.getInputMethodListeners()
,Component.getPropertyChangeListeners()
-
processEvent
protected void processEvent(AWTEvent e)
Processes events on this scroll bar. If the event is an instance ofAdjustmentEvent
, it invokes theprocessAdjustmentEvent
method. Otherwise, it invokes its superclass'sprocessEvent
method.Note that if the event parameter is
null
the behavior is unspecified and may result in an exception.- Overrides:
processEvent
in classComponent
- Parameters:
e
- the event- Since:
- JDK1.1
- See Also:
AdjustmentEvent
,processAdjustmentEvent(java.awt.event.AdjustmentEvent)
-
processAdjustmentEvent
protected void processAdjustmentEvent(AdjustmentEvent e)
Processes adjustment events occurring on this scrollbar by dispatching them to any registeredAdjustmentListener
objects.This method is not called unless adjustment events are enabled for this component. Adjustment events are enabled when one of the following occurs:
- An
AdjustmentListener
object is registered viaaddAdjustmentListener
. - Adjustment events are enabled via
enableEvents
.
Note that if the event parameter is
null
the behavior is unspecified and may result in an exception.- Parameters:
e
- the adjustment event- Since:
- JDK1.1
- See Also:
AdjustmentEvent
,AdjustmentListener
,addAdjustmentListener(java.awt.event.AdjustmentListener)
,Component.enableEvents(long)
- An
-
paramString
protected String paramString()
Returns a string representing the state of thisScrollbar
. 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 benull
.- Overrides:
paramString
in classComponent
- Returns:
- the parameter string of this scroll bar
-
getAccessibleContext
public AccessibleContext getAccessibleContext()
Gets theAccessibleContext
associated with thisScrollbar
. For scrollbars, theAccessibleContext
takes the form of anAccessibleAWTScrollBar
. A newAccessibleAWTScrollBar
instance is created if necessary.- Specified by:
getAccessibleContext
in interfaceAccessible
- Overrides:
getAccessibleContext
in classComponent
- Returns:
- an
AccessibleAWTScrollBar
that serves as theAccessibleContext
of thisScrollBar
- Since:
- 1.3
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-java/awt/Scrollbar.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.