Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.awt

Class Scrollbar

java.lang.Object
|
+--java.awt.Component
   |
   +--java.awt.Scrollbar

All Implemented Interfaces:

Accessible, Adjustable, ImageObserver, MenuContainer, Serializable


public class Scrollbar

extends Component

implements Accessible, Adjustable

This class implements a scrollbar widget.

Authors:

Field Summary

static intHORIZONTAL

Constant indicating that a scrollbar is horizontal.
static intVERTICAL

Constant indicating that a scrollbar is vertical.

Constructor Summary

Scrollbar()

Initializes a new instance of Scrollbar with a vertical orientation and default values for all other parameters.
Scrollbar(int orientation)

Initializes a new instance of Scrollbar with the specified orientation and default values for all other parameters.
Scrollbar(int orientation, int value, int visibleAmount, int minimum, int maximum)

Initializes a new instance of Scrollbar with the specified parameters.

Method Summary

synchronized voidaddAdjustmentListener(java.awt.event.AdjustmentListener listener)

Adds a new adjustment listener to the list of registered listeners for this object.
synchronized voidaddNotify()

Notifies this object to create its native peer.
java.awt.event.AdjustmentListener[]getAdjustmentListeners()

Returns an array of all registered adjustment listeners.
intgetBlockIncrement()

Returns the value added or subtracted when the user activates the scrollbar scroll by a "block" amount.
intgetLineIncrement()

Returns the value added or subtracted when the user selects the scrollbar scroll by a "unit" amount control.
java.util.EventListener[]getListeners(java.lang.Class listenerType)

Returns an array of all the objects currently registered as FooListeners upon this Scrollbar.
intgetMaximum()

Returns the maximum value for this scrollbar.
intgetMinimum()

Returns the minimum value for this scrollbar.
intgetOrientation()

Returns the orientation constant for this object.
intgetPageIncrement()

Returns the value added or subtracted when the user selects the scrollbar scroll by a "block" amount control.
intgetUnitIncrement()

Returns the value added or subtracted when the user activates the scrollbar scroll by a "unit" amount.
intgetValue()

Returns the current value for this scrollbar.
intgetVisible()

Returns the width of the scrollbar's thumb, in units relative to the maximum and minimum value of the scrollbar.
intgetVisibleAmount()

Returns the width of the scrollbar's thumb, in units relative to the maximum and minimum value of the scrollbar.
java.lang.StringparamString()

Returns a debugging string for this object.
voidprocessAdjustmentEvent(java.awt.event.AdjustmentEvent event)

Processes adjustment events for this object by dispatching them to any registered listeners.
voidprocessEvent(java.awt.AWTEvent event)

Processes events for this scrollbar.
synchronized voidremoveAdjustmentListener(java.awt.event.AdjustmentListener listener)

Removes the specified listener from the list of registered listeners for this object.
synchronized voidsetBlockIncrement(int blockIncrement)

Sets the value added or subtracted to the scrollbar value when the user selects the scroll by a "block" amount control.
voidsetLineIncrement(int lineIncrement)

Sets the value added or subtracted to the scrollbar value when the user selects the scroll by a "unit" amount control.
voidsetMaximum(int maximum)

Sets the maximum value for this scrollbar to the specified value.
voidsetMinimum(int minimum)

Sets the minimum value for this scrollbar to the specified value.
voidsetOrientation(int orientation)

Sets the orientation of this scrollbar to the specified value.
voidsetPageIncrement(int pageIncrement)

Sets the value added or subtracted to the scrollbar value when the user selects the scroll by a "block" amount control.
synchronized voidsetUnitIncrement(int unitIncrement)

Sets the value added or subtracted to the scrollbar value when the user selects the scroll by a "unit" amount control.
voidsetValue(int value)

Sets the current value for this scrollbar to the specified value.
synchronized voidsetValues(int value, int visibleAmount, int minimum, int maximum)

Sets the current value, visible amount, minimum, and maximum for this scrollbar.
voidsetVisibleAmount(int visibleAmount)

Sets the width of the scrollbar's thumb, in units relative to the maximum and minimum value of the scrollbar.

Field Details

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.


Constructor Details

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:


Method Details

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:


getLineIncrement

public int getLineIncrement()

Returns the value added or subtracted when the user selects the scrollbar scroll by a "unit" amount control.

Returns:


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:


getMaximum

public int getMaximum()

Returns the maximum value for this scrollbar.

Returns:


getMinimum

public int getMinimum()

Returns the minimum value for this scrollbar.

Returns:


getOrientation

public int getOrientation()

Returns the orientation constant for this object.

Returns:


getPageIncrement

public int getPageIncrement()

Returns the value added or subtracted when the user selects the scrollbar scroll by a "block" amount control.

Returns:


getUnitIncrement

public int getUnitIncrement()

Returns the value added or subtracted when the user activates the scrollbar scroll by a "unit" amount.

Returns:


getValue

public int getValue()

Returns the current value for this scrollbar.

Returns:


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:


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:


paramString

protected String paramString()

Returns a debugging string for this object.

Returns:


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: