java.awt
Class Scrollbar
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Scrollbar
All Implemented Interfaces:
Accessible, Adjustable, ImageObserver, MenuContainer, Serializable
This class implements a scrollbar widget.
Authors:- Aaron M. Renn (arenn@urbanophile.com)
- Tom Tromey <tromey@cygnus.com>
HORIZONTAL
public static final int HORIZONTAL
Constant indicating that a scrollbar is horizontal.
VERTICAL
public static final int VERTICAL
Constant indicating that a scrollbar is vertical.
Scrollbar
public Scrollbar()
Initializes a new instance of Scrollbar
with a
vertical orientation and default values for all other parameters.
Throws:
Scrollbar
public Scrollbar(int orientation)
Initializes a new instance of Scrollbar
with the
specified orientation and default values for all other parameters.
The orientation must be either the constant HORIZONTAL
or
VERTICAL
from this class. An incorrect value will throw
an exception.
Parameters:
Throws:
Scrollbar
public Scrollbar(int orientation, int value, int visibleAmount, int minimum, int maximum)
Initializes a new instance of Scrollbar
with the
specified parameters. The orientation must be either the constant
HORIZONTAL
or VERTICAL
. An incorrect value
will throw an exception. Inconsistent values for other parameters
are silently corrected to valid values.
Parameters:
Throws:
addAdjustmentListener
public synchronized void addAdjustmentListener(java.awt.event.AdjustmentListener listener)
Adds a new adjustment listener to the list of registered listeners
for this object.
Parameters:
addNotify
public synchronized void addNotify()
Notifies this object to create its native peer.
getAdjustmentListeners
public AdjustmentListener[] getAdjustmentListeners()
Returns an array of all registered adjustment listeners.
getBlockIncrement
public int getBlockIncrement()
Returns the value added or subtracted when the user activates the scrollbar
scroll by a "block" amount.
Returns:
- The block increment value.
getLineIncrement
public int getLineIncrement()
Returns the value added or subtracted when the user selects the scrollbar
scroll by a "unit" amount control.
Returns:
- The unit increment value.
getListeners
public EventListener[] getListeners(java.lang.Class listenerType)
Returns an array of all the objects currently registered as FooListeners
upon this Scrollbar
. FooListeners are registered using the
addFooListener method.
Parameters:
Throws:
ClassCastException
- If listenerType doesn't specify a class or
interface that implements java.util.EventListener.
getMaximum
public int getMaximum()
Returns the maximum value for this scrollbar.
Returns:
- The maximum value for this scrollbar.
getMinimum
public int getMinimum()
Returns the minimum value for this scrollbar.
Returns:
- The minimum value for this scrollbar.
getOrientation
public int getOrientation()
Returns the orientation constant for this object.
Returns:
- The orientation constant for this object.
getPageIncrement
public int getPageIncrement()
Returns the value added or subtracted when the user selects the scrollbar
scroll by a "block" amount control.
Returns:
- The block increment value.
getUnitIncrement
public int getUnitIncrement()
Returns the value added or subtracted when the user activates the scrollbar
scroll by a "unit" amount.
Returns:
- The unit increment value.
getValue
public int getValue()
Returns the current value for this scrollbar.
Returns:
- The current value for this scrollbar.
getVisible
public int getVisible()
Returns the width of the scrollbar's thumb, in units relative to the
maximum and minimum value of the scrollbar.
Returns:
- The width of the scrollbar's thumb.
getVisibleAmount
public int getVisibleAmount()
Returns the width of the scrollbar's thumb, in units relative to the
maximum and minimum value of the scrollbar.
Returns:
- The width of the scrollbar's thumb.
paramString
protected String paramString()
Returns a debugging string for this object.
Returns:
- A debugging string for this object.
processAdjustmentEvent
protected void processAdjustmentEvent(java.awt.event.AdjustmentEvent event)
Processes adjustment events for this object by dispatching them to
any registered listeners. Note that this method will only be called
if adjustment events are enabled. This will happen automatically if
any listeners are registered. Otherwise, it can be enabled by a
call to enableEvents()
.
Parameters:
processEvent
protected void processEvent(java.awt.AWTEvent event)
Processes events for this scrollbar. It does this by calling
processAdjustmentEvent()
if the event is an instance of
AdjustmentEvent
, otherwise it calls the superclass to
process the event.
Parameters:
removeAdjustmentListener
public synchronized void removeAdjustmentListener(java.awt.event.AdjustmentListener listener)
Removes the specified listener from the list of registered listeners
for this object.
Parameters:
setBlockIncrement
public synchronized void setBlockIncrement(int blockIncrement)
Sets the value added or subtracted to the scrollbar value when the
user selects the scroll by a "block" amount control.
Parameters:
setLineIncrement
public void setLineIncrement(int lineIncrement)
Sets the value added or subtracted to the scrollbar value when the
user selects the scroll by a "unit" amount control.
Parameters:
setMaximum
public void setMaximum(int maximum)
Sets the maximum value for this scrollbar to the specified value.
If the value is less than the current minimum value, it is silent
set to equal the minimum value.
Parameters:
setMinimum
public void setMinimum(int minimum)
Sets the minimum value for this scrollbar to the specified value. If
this is not consistent with the current value and maximum, it is
silently adjusted to be consistent.
Parameters:
setOrientation
public void setOrientation(int orientation)
Sets the orientation of this scrollbar to the specified value. This
value must be either the constant HORIZONTAL
or
VERTICAL
from this class or an exception will be thrown.
Parameters:
Throws:
setPageIncrement
public void setPageIncrement(int pageIncrement)
Sets the value added or subtracted to the scrollbar value when the
user selects the scroll by a "block" amount control.
Parameters:
setUnitIncrement
public synchronized void setUnitIncrement(int unitIncrement)
Sets the value added or subtracted to the scrollbar value when the
user selects the scroll by a "unit" amount control.
Parameters:
setValue
public void setValue(int value)
Sets the current value for this scrollbar to the specified value.
If this is inconsistent with the minimum and maximum values for this
scrollbar, the value is silently adjusted.
Parameters:
setValues
public synchronized void setValues(int value, int visibleAmount, int minimum, int maximum)
Sets the current value, visible amount, minimum, and maximum for this
scrollbar. These values are adjusted to be internally consistent
if necessary.
Parameters:
setVisibleAmount
public void setVisibleAmount(int visibleAmount)
Sets the width of the scrollbar's thumb, in units relative to the
maximum and minimum value of the scrollbar.
Parameters: