home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Java AWT

Previous Chapter 19
java.awt Reference
Next
 

Scrollbar

Name

Scrollbar

[Graphic: Figure from the text]

Description

The Scrollbar is a Component that provides the means to get and set values within a predetermined range. For example, a scrollbar could be used for a volume control. Scrollbars are most frequently used to help users manipulate areas too large to be displayed on the screen (pre version 1.1) or to set a value within an integer range.

Class Definition

public class java.awt.Scrollbar
    extends java.awt.Component
    implements java.awt.Adjustable {
  
  // Constants
  public final static int HORIZONTAL;
  public final static int VERTICAL;
  
  // Constructors
  public Scrollbar();
  public Scrollbar (int orientation);
  public Scrollbar (int orientation, int value, int visible, int minimum, 
    int maximum);
  
  // Instance Methods
  public void addAdjustmentListener (AdjustmentListener l); (New)
  public void addNotify();
  public int getBlockIncrement(); (New)
  public int getLineIncrement(); (Deprecated)
  public int getMaximum();
  public int getMinimum();
  public int getOrientation();
  public int getPageIncrement(); (Deprecated)
  public int getUnitIncrement(); (New)
  public int getValue();
  public int getVisible(); (Deprecated)
  public int getVisibleAmount(); (New)
  public void removeAdjustmentListener (AdjustmentListener l); (New)
  public synchronized void setBlockIncrement (int v); (New)
  public void setLineIncrement (int amount); (Deprecated)
  public synchronized void setMaximum (int newMaximum); (New)
  public synchronized void setMinimum (int newMinimum); (New)
  public synchronized void setOrientation (int orientation); (New)
  public void setPageIncrement (int amount); (Deprecated)
  public synchronized void setUnitIncrement(int v); (New)
  public synchronized void setValue (int value);
  public synchronized void setValues (int value, int visible, 
    int minimum, int maximum);
  public synchronized void setVisibleAmount (int newAmount); (New)
  
  // Protected Instance Methods
  protected String paramString();
  protected void processAdjustmentEvent (AdjustmentEvent e); (New)
  protected void processEvent (AWTEvent e); (New)
}

Constants

HORIZONTAL

public final static int HORIZONTAL

Constant used for a Scrollbar with a horizontal orientation.

VERTICAL

public final static int VERTICAL

Constant used for a Scrollbar with a vertical orientation.

Constructors

Scrollbar

public Scrollbar()

Description

Constructs a vertical Scrollbar object; slider size, minimum value, maximum value, and initial value are all zero.

public Scrollbar (int orientation)

Parameters

orientation

Scrollbar constant designating direction.

Throws

IllegalArgumentException

If orientation is invalid.

Description

Constructs a Scrollbar object, in the designated direction; slider size, minimum value, maximum value, and initial value are all zero.

public Scrollbar (int orientation, int value, int visible, int minimum, int maximum)

Parameters

orientation

Scrollbar constant designating direction.

value

Initial value of Scrollbar.

visible

Initial slider size.

minimum

Initial minimum value.

maximum

Initial maximum value.

Throws

IllegalArgumentException

If orientation is invalid.

Description

Constructs a Scrollbar object with the given values.

Instance Methods

addAdjustmentListener

public void addAdjustmentListener (AdjustmentListener l) (New)

Parameters

l

An object that implements the AdjustmentListener interface.

Implements

Adjustable.addAdjustmentListener()

Description

Add a listener for adjustment event.

addNotify

public void addNotify()

Overrides

Component.addNotify()

Description

Creates Scrollbar's peer.

getBlockIncrement

public int getBlockIncrement() (New)

Implements

Adjustable.getBlockIncrement()

Returns

The amount to scroll when a paging area is selected.

getLineIncrement

public int getLineIncrement() (Deprecated)

Returns

The amount to scroll when one of the arrows at the ends of the scrollbar is selected. Replaced by getUnitIncrement().

getMaximum

public int getMaximum()

Implements

Adjustable.getMaximum()

Returns

The maximum value that the Scrollbar can take.

getMinimum

public int getMinimum()

Implements

Adjustable.getMinimum()

Returns

The minimum value that the Scrollbar can take.

getOrientation

public int getOrientation()

Implements

Adjustable.getOrientation()

Returns

A constant representing the direction of the Scrollbar.

getPageIncrement

public int getPageIncrement() (Deprecated)

Returns

The amount to scroll when a paging area is selected. Replaced with getBlockIncrement().

getUnitIncrement

public int getUnitIncrement() (New)

Implements

Adjustable.getUnitIncrement()

Returns

The amount to scroll when one of the arrows at the ends of the scrollbar is selected.

getValue

public int getValue()

Implements

Adjustable.getValue()

Returns

The current setting for the Scrollbar.

getVisible

public int getVisible() (Deprecated)

Returns

The current visible setting (i.e., size) for the slider. Replaced by getVisibleAmount().

getVisibleAmount

public int getVisibleAmount() (New)

Implements

Adjustable.getVisibleAmount()

Returns

The current visible setting (i.e., size) for the slider.

removeAdjustmentListener

public void removeAdjustmentListener (AdjustmentListener l) (New)

Parameters

l

One of this Scrollbar's AdjustmentListeners.

Implements

Adjustable.removeAdjustmentListener()

Description

Remove an adjustment event listener.

setBlockIncrement

public synchronized void setBlockIncrement (int amount) (New)

Parameters

amount

New paging increment amount.

Implements

Adjustable.setBlockIncrement()

Description

Changes the block increment amount for the Scrollbar; the default block increment is 10.

setLineIncrement

public void setLineIncrement (int amount) (Deprecated)

Parameters

amount

New line increment amount.

Description

Changes the line increment amount for the Scrollbar. The default line increment is 1. Replaced by setUnitIncrement(int).

setMaximum

public synchronized void setMaximum (int newMaximum) (New)

Parameters

newMaximum

New maximum value.

Implements

Adjustable.setMaximum()

Description

Changes the maximum value for the Scrollbar.

setMinimum

public synchronized void setMinimum (int newMinimum) (New)

Parameters

newMinimum

New minimum value.

Implements

Adjustable.setMinimum()

Description

Changes the minimum value for the Scrollbar.

setOrientation

public synchronized void setOrientation (int orientation) (New)

Parameters

orientation

One of the orientation constants HORIZONTAL or VERTICAL.

Description

Changes the orientation of the Scrollbar.

setPageIncrement

public void setPageIncrement (int amount) (Deprecated)

Parameters

amount

New paging increment amount.

Description

Changes the paging increment amount for the Scrollbar; the default page increment is 10. Replaced by setBlockIncrement(int).

setUnitIncrement

public synchronized void setUnitIncrement (int amount) (New)

Parameters

amount

New line increment amount.

Implements

Adjustable.setUnitIncrement()

Description

Changes the unit increment amount for the Scrollbar. The default unit increment is 1.

setValue

public synchronized void setValue (int value)

Parameters

value

New Scrollbar value.

Implements

Adjustable.setValue()

Description

Changes the current value of the Scrollbar.

setValues

public synchronized void setValues (int value, int visible, int minimum, int maximum)

Parameters

value

New Scrollbar value.

visible

New slider width.

minimum

New minimum value for Scrollbar.

maximum

New maximum value for Scrollbar.

Description

Changes the settings of the Scrollbar to the given amounts.

setVisibleAmount

public synchronized void setVisibleAmount (int newAmount) (New)

Parameters

newAmount

New amount visible.

Implements

Adjustable.setVisibleAmount()

Description

Changes the current visible amount of the Scrollbar.

Protected Instance Methods

paramString

protected String paramString()

Returns

String with current settings of Scrollbar.

Overrides

Component.paramString()

Description

Helper method for toString() to generate string of current settings.

processAdjustmentEvent

protected void processAdjustmentEvent (AdjustmentEvent e) (New)

Parameters

e

The adjustment event to process.

Description

Adjustment events are passed to this method for processing. Normally, this method is called by processEvent().

processEvent

protected void processEvent (AWTEvent e) (New)

Parameters

e

The event to process.

Description

Low level AWTEvents are passed to this method for processing.

See Also

Adjustable, Component, String


Previous Home Next
ScrollPane (New) Book Index Shape (New)

Java in a Nutshell Java Language Reference Java AWT Java Fundamental Classes Exploring Java