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
-
hbar
-
-
vbar
-
-
viewport
- The viewport displays the visible portion of whatever is being scrolled.
-
Scroller()
- Straightforward constructor.
-
adjustmentValueChanged(AdjustmentEvent)
- Respond to a change in a scrollbar position.
-
getScrollAreaSize()
- Report the size of the object being scrolled.
-
getScrollPosition()
- Get the current x,y position that is displayed in the viewport.
-
getViewportSize()
- Get the current size of the viewport.
-
manageHorizontalScrollbar()
- Control the visibility of the horizontal scrollbar.
-
manageScrollbars()
- Control the visibility of the scrollbars.
-
manageVerticalScrollbar()
- Control the visibility of the vertical scrollbar.
-
paint(Graphics)
-
-
scroll()
- Scroll to the position of the current scrollbar values.
-
scrollAbsolute()
- Perform the scrolling for a scrollbar TRACK adjustment event.
-
scrollLineDown()
- Perform the scrolling for a scrollbar UNIT_DECREMENT adjustment event.
-
scrollLineUp()
- Perform the scrolling for a scrollbar UNIT_INCREMENT adjustment event.
-
scrollPageDown()
- Perform the scrolling for a scrollbar BLOCK_DECREMENT adjustment event.
-
scrollPageUp()
- Perform the scrolling for a scrollbar BLOCK_INCREMENT adjustment event.
-
scrollTo(int, int)
- Scroll to position (x,y).
-
setHorizontalLineAndPageIncrements()
- Set the line and page increments for the horizontal scrollbar.
-
setHorizontalScrollbarValues()
- Set the horizontal scrollbar properties.
-
setScrollbarValues()
- Set the Scrollbars properties.
-
setScrollPosition(int, int)
- Scroll to position (x,y).
-
setScrollPosition(Point)
- Scroll to position (x,y).
-
setVerticalLineAndPageIncrements()
- Set the line and page increments for the vertical scrollbar.
-
setVerticalScrollbarValues()
- Set the vertical scrollbar properties.
-
update(Graphics)
- Update the display screen.
hbar
protected Scrollbar hbar
vbar
protected Scrollbar vbar
viewport
protected Panel viewport
- The viewport displays the visible portion of whatever is being scrolled.
Scroller
public Scroller()
- Straightforward constructor.
The layout manager is set to ScrollerLayout.
- See Also:
- ScrollerLayout
getScrollAreaSize
public abstract Dimension getScrollAreaSize()
- Report the size of the object being scrolled.
- Returns:
- the Dimension of the object being scrolled.
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.
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
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
getViewportSize
public Dimension getViewportSize()
- Get the current size of the viewport.
- Returns:
- the size of the viewport in pixels.
- See Also:
- ScrollPane
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
paint
public void paint(Graphics g)
- Overrides:
- paint in class Container
setScrollbarValues
public void setScrollbarValues()
- Set the Scrollbars properties.
This method interfaces to the layout manager.
- See Also:
- ScrollerLayout, Scrollbar
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
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
update
public void update(Graphics g)
- Update the display screen.
Modified from the default action to eliminate screen flicker.
- Overrides:
- update in class Container
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
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
scroll
protected void scroll()
- Scroll to the position of the current scrollbar values.
scrollAbsolute
protected void scrollAbsolute()
- Perform the scrolling for a scrollbar TRACK adjustment event.
- See Also:
- adjustmentValueChanged, AdjustmentEvent
scrollLineDown
protected void scrollLineDown()
- Perform the scrolling for a scrollbar UNIT_DECREMENT adjustment event.
- See Also:
- adjustmentValueChanged, AdjustmentEvent
scrollLineUp
protected void scrollLineUp()
- Perform the scrolling for a scrollbar UNIT_INCREMENT adjustment event.
- See Also:
- adjustmentValueChanged, AdjustmentEvent
scrollPageDown
protected void scrollPageDown()
- Perform the scrolling for a scrollbar BLOCK_DECREMENT adjustment event.
- See Also:
- adjustmentValueChanged, AdjustmentEvent
scrollPageUp
protected void scrollPageUp()
- Perform the scrolling for a scrollbar BLOCK_INCREMENT adjustment event.
- See Also:
- adjustmentValueChanged, AdjustmentEvent
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
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
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
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