Class Scroller

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----Scroller

public abstract class Scroller
extends Panel
implements AdjustmentListener
An abstract class for generic scrolling. Only two methods need to be overriden: getScrollAreaSize which returns the size of whatever is being scrolled, and scrollTo which performs the work of scrolling to a particular location. A special layout manager has been developed. Based on class Scroller from "Graphic Java 1.1" p. 792. An alternative is ScrollPane. Java 1.1 Implementation

See Also:
getScrollAreaSize, scrollTo, ScrollerLayout, AdjustmentListener, Scrollbar, ScrollPane, Panel

Variable Index

 o hbar
 o vbar
 o viewport
The viewport displays the visible portion of whatever is being scrolled.

Constructor Index

 o Scroller()
Straightforward constructor.

Method Index

 o adjustmentValueChanged(AdjustmentEvent)
Respond to a change in a scrollbar position.
 o getScrollAreaSize()
Report the size of the object being scrolled.
 o getScrollPosition()
Get the current x,y position that is displayed in the viewport.
 o getViewportSize()
Get the current size of the viewport.
 o manageHorizontalScrollbar()
Control the visibility of the horizontal scrollbar.
 o manageScrollbars()
Control the visibility of the scrollbars.
 o manageVerticalScrollbar()
Control the visibility of the vertical scrollbar.
 o paint(Graphics)
 o scroll()
Scroll to the position of the current scrollbar values.
 o scrollAbsolute()
Perform the scrolling for a scrollbar TRACK adjustment event.
 o scrollLineDown()
Perform the scrolling for a scrollbar UNIT_DECREMENT adjustment event.
 o scrollLineUp()
Perform the scrolling for a scrollbar UNIT_INCREMENT adjustment event.
 o scrollPageDown()
Perform the scrolling for a scrollbar BLOCK_DECREMENT adjustment event.
 o scrollPageUp()
Perform the scrolling for a scrollbar BLOCK_INCREMENT adjustment event.
 o scrollTo(int, int)
Scroll to position (x,y).
 o setHorizontalLineAndPageIncrements()
Set the line and page increments for the horizontal scrollbar.
 o setHorizontalScrollbarValues()
Set the horizontal scrollbar properties.
 o setScrollbarValues()
Set the Scrollbars properties.
 o setScrollPosition(int, int)
Scroll to position (x,y).
 o setScrollPosition(Point)
Scroll to position (x,y).
 o setVerticalLineAndPageIncrements()
Set the line and page increments for the vertical scrollbar.
 o setVerticalScrollbarValues()
Set the vertical scrollbar properties.
 o update(Graphics)
Update the display screen.

Variables

 o hbar
 protected Scrollbar hbar
 o vbar
 protected Scrollbar vbar
 o viewport
 protected Panel viewport
The viewport displays the visible portion of whatever is being scrolled.

Constructors

 o Scroller
 public Scroller()
Straightforward constructor. The layout manager is set to ScrollerLayout.

See Also:
ScrollerLayout

Methods

 o getScrollAreaSize
 public abstract Dimension getScrollAreaSize()
Report the size of the object being scrolled.

Returns:
the Dimension of the object being scrolled.
 o scrollTo
 protected abstract void scrollTo(int x,
                                  int y)
Scroll to position (x,y). This method performs the work of scrolling to a particular location.

Parameters:
x - the value of the horizontal scrollbar.
y - the value of the vertical scrollbar.
 o adjustmentValueChanged
 public void adjustmentValueChanged(AdjustmentEvent event)
Respond to a change in a scrollbar position. If the AdjustmentEvent is unknown then an error message is printed.

Parameters:
event - the Scrollbar event.
See Also:
AdjustmentListener
 o getScrollPosition
 public Point getScrollPosition()
Get the current x,y position that is displayed in the viewport. This is a convenience method which interfaces with the Adjustable objects that respresent the state of the scrollbars.

Returns:
the coordinates of the current scroll position.
See Also:
ScrollPane, Scrollbar, Adjustable
 o getViewportSize
 public Dimension getViewportSize()
Get the current size of the viewport.

Returns:
the size of the viewport in pixels.
See Also:
ScrollPane
 o manageScrollbars
 public void manageScrollbars()
Control the visibility of the scrollbars. It is determined from the sizes of the viewport and the object being scrolled. This method interfaces to the layout manager.

See Also:
ScrollerLayout, Scrollbar
 o paint
 public void paint(Graphics g)
Overrides:
paint in class Container
 o setScrollbarValues
 public void setScrollbarValues()
Set the Scrollbars properties. This method interfaces to the layout manager.

See Also:
ScrollerLayout, Scrollbar
 o setScrollPosition
 public void setScrollPosition(int x,
                               int y)
Scroll to position (x,y). This is a convenience method which interfaces with the Adjustable objects that respresent the state of the scrollbars. In other words this is for programmatic scrolling.

Parameters:
x - scroll to this value of the horizontal scrollbar.
y - scroll to this value of the vertical scrollbar.
See Also:
ScrollPane, Scrollbar, Adjustable
 o setScrollPosition
 public void setScrollPosition(Point p)
Scroll to position (x,y). This is a convenience method which interfaces with the Adjustable objects that respresent the state of the scrollbars. In other words this is for programmatic scrolling.

Parameters:
p - the Point representing the values of the scrollbars.
See Also:
ScrollPane, Scrollbar, Adjustable
 o update
 public void update(Graphics g)
Update the display screen. Modified from the default action to eliminate screen flicker.

Overrides:
update in class Container
 o manageHorizontalScrollbar
 protected void manageHorizontalScrollbar()
Control the visibility of the horizontal scrollbar. It is determined from the sizes of the Scroller and the object being scrolled.

See Also:
Scrollbar
 o manageVerticalScrollbar
 protected void manageVerticalScrollbar()
Control the visibility of the vertical scrollbar. It is determined from the sizes of the Scroller and the object being scrolled.

See Also:
Scrollbar
 o scroll
 protected void scroll()
Scroll to the position of the current scrollbar values.

 o scrollAbsolute
 protected void scrollAbsolute()
Perform the scrolling for a scrollbar TRACK adjustment event.

See Also:
adjustmentValueChanged, AdjustmentEvent
 o scrollLineDown
 protected void scrollLineDown()
Perform the scrolling for a scrollbar UNIT_DECREMENT adjustment event.

See Also:
adjustmentValueChanged, AdjustmentEvent
 o scrollLineUp
 protected void scrollLineUp()
Perform the scrolling for a scrollbar UNIT_INCREMENT adjustment event.

See Also:
adjustmentValueChanged, AdjustmentEvent
 o scrollPageDown
 protected void scrollPageDown()
Perform the scrolling for a scrollbar BLOCK_DECREMENT adjustment event.

See Also:
adjustmentValueChanged, AdjustmentEvent
 o scrollPageUp
 protected void scrollPageUp()
Perform the scrolling for a scrollbar BLOCK_INCREMENT adjustment event.

See Also:
adjustmentValueChanged, AdjustmentEvent
 o setHorizontalLineAndPageIncrements
 protected void setHorizontalLineAndPageIncrements()
Set the line and page increments for the horizontal scrollbar. The line increment is one tenth the scroll area size; the page is two tenths.

See Also:
Scrollbar
 o setHorizontalScrollbarValues
 protected void setHorizontalScrollbarValues()
Set the horizontal scrollbar properties. The values are determined from the sizes of the viewport and the object being scrolled.

See Also:
Scrollbar
 o setVerticalLineAndPageIncrements
 protected void setVerticalLineAndPageIncrements()
Set the line and page increments for the vertical scrollbar. The line increment is one tenth the scroll area size; the page is two tenths.

See Also:
Scrollbar
 o setVerticalScrollbarValues
 protected void setVerticalScrollbarValues()
Set the vertical scrollbar properties. The values are determined from the sizes of the viewport and the object being scrolled.

See Also:
Scrollbar