java::awt::Scrollbar Class Reference

Inheritance diagram for java::awt::Scrollbar:

Inheritance graph
java::awt::Componentjava::lang::Objectjava::lang::Interfacejava::lang::Syncjava::awt::event::ComponentSourcejava::awt::event::FocusSourcejava::awt::event::HierarchySourcejava::awt::event::KeySourcejava::awt::event::MouseSourcejava::awt::event::PaintSourcejava::util::PropertyChangeSourcejava::awt::event::AdjustmentSourcejava::lang::Lockjava::lang::ScopeAdapterjava::awt::image::ImageObserverjava::util::EventSourcejava::awt::Adjustable
[legend]
Collaboration diagram for java::awt::Scrollbar:

Collaboration graph
java::awt::Componentjava::lang::Objectjava::lang::Interfacejava::lang::ObjectRefjava::lang::Syncjava::awt::event::ComponentSourcejava::awt::event::FocusSourcejava::awt::event::HierarchySourcejava::awt::event::KeySourcejava::awt::event::MouseSourcejava::awt::event::PaintSourcejava::util::PropertyChangeSourcejava::awt::event::AdjustmentSourcejava::lang::Lockjava::lang::ScopeAdapterjava::lang::Comparablejava::awt::image::ImageObserverjava::util::EventSourcejava::util::Collectionjava::awt::Adjustablejava::util::LinkedListjava::util::AbstractSequentialListjava::util::AbstractListjava::util::AbstractCollectionjava::util::List
[legend]

List of all members.


Detailed Description

The Scrollbar 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:

Scrollbar-1.gif

Each scroll bar in this example could be created with code similar to the following:


<blockquote>
 redSlider=new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, 255);
 add(redSlider);
 
</blockquote>

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" or "thumb" can represent the amount of text that is visible. Here is an example of a scroll bar that represents a range:

Scrollbar-2.gif

The value range represented by the bubble is the visible range of the scroll bar. The horizontal scroll bar in this example could be created with code like the following:


<blockquote>
 ranger = new Scrollbar(Scrollbar.HORIZONTAL, 0, 60, 0, 300);
 add(ranger);
 
</blockquote>

Note that the actual maximum value of the scroll bar is the maximum minus the visible. In the previous example, because the maximum is 300 and the visible 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 package java.awt.event. Listeners can be added and removed dynamically by calling the methods addAdjustmentListener and removeAdjustmentListener.

The AdjustmentEvent class defines five types of adjustment event, listed here:

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

Version:
1.98, 01/23/03
Author:
Sami Shaio
See also:
java.awt.event.AdjustmentEvent

java.awt.event.AdjustmentListener

Since:
JDK1.0

Public Member Functions

 Scrollbar (jint orientation=HORIZONTAL, jint value=0, jint visible=10, jint minimum=0, jint maximum=100)
 Constructs a new scroll bar with the specified orientation, initial value, visible amount, and minimum and maximum values.
virtual jint getOrientation () const
 Returns the orientation of this scroll bar.
virtual void setOrientation (jint orientation)
 Sets the orientation for this scroll bar.
virtual jint getValue () const
 Gets the current value of this scroll bar.
virtual void setValue (jint newValue)
 Sets the value of this scroll bar to the specified value.
virtual jint getMinimum () const
 Gets the minimum value of this scroll bar.
virtual void setMinimum (jint newMinimum)
 Sets the minimum value of this scroll bar.
virtual jint getMaximum () const
 Gets the maximum value of this scroll bar.
virtual void setMaximum (jint newMaximum)
 Sets the maximum value of this scroll bar.
virtual jint getVisibleAmount () const
 Gets the visible amount of this scroll bar.
virtual void setVisibleAmount (jint newAmount)
 Sets the visible amount of this scroll bar.
virtual jint getUnitIncrement () const
 Gets the unit increment for this scrollbar.
virtual void setUnitIncrement (jint v)
 Sets the unit increment for this scroll bar.
virtual jint getBlockIncrement () const
 Gets the block increment of this scroll bar.
virtual void setBlockIncrement (jint v)
 Sets the block increment for this scroll bar.
virtual void setValues (jint value, jint visible, jint minimum, jint maximum)
 Sets the values of four properties for this scroll bar: value, visibleAmount, minimum, and maximum.
virtual jboolean getValueIsAdjusting () const
 Returns true if the value is in the process of changing as a result of actions being taken by the user.
virtual void setValueIsAdjusting (jboolean b)
 Sets the valueIsAdjusting property.
virtual String toString () const
 Returns a string representation of this component and its values.

Constructor & Destructor Documentation

java::awt::Scrollbar::Scrollbar ( jint  orientation = HORIZONTAL,
jint  value = 0,
jint  visible = 10,
jint  minimum = 0,
jint  maximum = 100 
)

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 values Scrollbar.HORIZONTAL, or Scrollbar.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 bar
visible the size of the scroll bar's bubble, representing the visible portion.
minimum the minimum value of the scroll bar
maximum the maximum value of the scroll bar
Exceptions:
IllegalArgumentException when an illegal value for the orientation argument is supplied
HeadlessException if GraphicsEnvironment.isHeadless() returns true.
See also:
setValues

java.awt.GraphicsEnvironment::isHeadless


Member Function Documentation

virtual jint java::awt::Scrollbar::getOrientation (  )  const [virtual]

Returns the orientation of this scroll bar.

Returns:
the orientation of this scroll bar, either Scrollbar.HORIZONTAL or Scrollbar.VERTICAL
See also:
java.awt.Scrollbar::setOrientation

Implements java::awt::Adjustable.

virtual void java::awt::Scrollbar::setOrientation ( jint  orientation  )  [virtual]

Sets the orientation for this scroll bar.

Parameters:
orientation the orientation of this scroll bar, either Scrollbar.HORIZONTAL or Scrollbar.VERTICAL
See also:
java.awt.Scrollbar::getOrientation
Exceptions:
IllegalArgumentException if the value supplied for orientation is not a legal value
Since:
JDK1.1

virtual jint java::awt::Scrollbar::getValue (  )  const [virtual]

Gets the current value of this scroll bar.

Returns:
the current value of this scroll bar
See also:
java.awt.Scrollbar::getMinimum

java.awt.Scrollbar::getMaximum

Implements java::awt::Adjustable.

virtual void java::awt::Scrollbar::setValue ( jint  newValue  )  [virtual]

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 current maximum - visibleAmount, then one of those values is substituted, as appropriate.

Normally, a program should change a scroll bar's value only by calling setValues. The setValues method simultaneously and synchronously sets the minimum, maximum, visible amount, and value properties of a scroll bar, so that they are mutually consistent.

Parameters:
newValue the new value of the scroll bar
See also:
java.awt.Scrollbar::setValues

java.awt.Scrollbar::getValue

java.awt.Scrollbar::getMinimum

java.awt.Scrollbar::getMaximum

Implements java::awt::Adjustable.

virtual jint java::awt::Scrollbar::getMinimum (  )  const [virtual]

Gets the minimum value of this scroll bar.

Returns:
the minimum value of this scroll bar
See also:
java.awt.Scrollbar::getValue

java.awt.Scrollbar::getMaximum

Implements java::awt::Adjustable.

virtual void java::awt::Scrollbar::setMinimum ( jint  newMinimum  )  [virtual]

Sets the minimum value of this scroll bar.

When setMinimum is called, the limiting argument takes precedence over the existing scrollbar value.

Normally, a program should change a scroll bar's minimum value only by calling setValues. The setValues 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.MIN_VALUE will result in the new minimum value to be set to Integer.MIN_VALUE - 1.

Parameters:
newMinimum the new minimum value for this scroll bar
See also:
java.awt.Scrollbar::setValues

java.awt.Scrollbar::setMaximum

Since:
JDK1.1

Implements java::awt::Adjustable.

virtual jint java::awt::Scrollbar::getMaximum (  )  const [virtual]

Gets the maximum value of this scroll bar.

Returns:
the maximum value of this scroll bar
See also:
java.awt.Scrollbar::getValue

java.awt.Scrollbar::getMinimum

Implements java::awt::Adjustable.

virtual void java::awt::Scrollbar::setMaximum ( jint  newMaximum  )  [virtual]

Sets the maximum value of this scroll bar.

When setMaximum is called, the limiting argument takes precedence over the existing scrollbar value.

Normally, a program should change a scroll bar's maximum value only by calling setValues. The setValues method simultaneously and synchronously sets the minimum, maximum, visible amount, and value properties of a scroll bar, so that they are mutually consistent.

Parameters:
newMaximum the new maximum value for this scroll bar
See also:
java.awt.Scrollbar::setValues

java.awt.Scrollbar::setMinimum

Since:
JDK1.1

Implements java::awt::Adjustable.

virtual jint java::awt::Scrollbar::getVisibleAmount (  )  const [virtual]

Gets the visible amount of this scroll bar.

The visible amount of a scroll bar is the range of values represented by the width of the scroll bar's bubble.

Returns:
the visible amount of this scroll bar
See also:
java.awt.Scrollbar::setVisibleAmount
Since:
JDK1.1

Implements java::awt::Adjustable.

virtual void java::awt::Scrollbar::setVisibleAmount ( jint  newAmount  )  [virtual]

Sets the visible amount of this scroll bar.

The visible amount of a scroll bar is the range of values represented by the width of the scroll bar's bubble.

Normally, a program should change a scroll bar's value only by calling setValues. The setValues method simultaneously and synchronously sets the minimum, maximum, visible amount, and value properties of a scroll bar, so that they are mutually consistent.

Parameters:
newAmount the amount visible per page
See also:
java.awt.Scrollbar::getVisibleAmount

java.awt.Scrollbar::setValues

Since:
JDK1.1

Implements java::awt::Adjustable.

virtual jint java::awt::Scrollbar::getUnitIncrement (  )  const [virtual]

Gets the unit increment for this scrollbar.

The unit increment is the value that is added (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.

Returns:
the unit increment of this scroll bar
See also:
java.awt.Scrollbar::setUnitIncrement
Since:
JDK1.1

Implements java::awt::Adjustable.

virtual void java::awt::Scrollbar::setUnitIncrement ( jint  v  )  [virtual]

Sets the unit increment for this scroll bar.

The unit increment is the value that is added (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.

Parameters:
v the amount by which to increment or decrement the scroll bar's value
See also:
java.awt.Scrollbar::getUnitIncrement
Since:
JDK1.1

Implements java::awt::Adjustable.

virtual jint java::awt::Scrollbar::getBlockIncrement (  )  const [virtual]

Gets the block increment of this scroll bar.

The block increment is the value that is added (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.

Returns:
the block increment of this scroll bar
See also:
java.awt.Scrollbar::setBlockIncrement
Since:
JDK1.1

Implements java::awt::Adjustable.

virtual void java::awt::Scrollbar::setBlockIncrement ( jint  v  )  [virtual]

Sets the block increment for this scroll bar.

The block increment is the value that is added (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.

Parameters:
v the amount by which to increment or decrement the scroll bar's value
See also:
java.awt.Scrollbar::getBlockIncrement
Since:
JDK1.1

Implements java::awt::Adjustable.

virtual void java::awt::Scrollbar::setValues ( jint  value,
jint  visible,
jint  minimum,
jint  maximum 
) [virtual]

Sets the values of four properties for this scroll bar: value, visibleAmount, minimum, and maximum.

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 than minimum, visibleAmount must be positive, visibleAmount must not be greater than maximum - minimum, value must not be less than minimum, and value must not be greater than maximum - visibleAmount

Parameters:
value is the position in the current window
visible is the amount visible per page
minimum is the minimum value of the scroll bar
maximum is the maximum value of the scroll bar
See also:
setMinimum

setMaximum

setVisibleAmount

setValue

virtual jboolean java::awt::Scrollbar::getValueIsAdjusting (  )  const [virtual]

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
See also:
setValueIsAdjusting
Since:
1.4

virtual void java::awt::Scrollbar::setValueIsAdjusting ( jboolean  b  )  [virtual]

Sets the valueIsAdjusting property.

Parameters:
b new adjustment-in-progress status
See also:
getValueIsAdjusting
Since:
1.4

virtual String java::awt::Scrollbar::toString (  )  const [virtual]

Returns a string representation of this component and its values.

Returns:
a string representation of this component
Since:
JDK1.0

Reimplemented from java::awt::Component.


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:08 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3