Class tea.set.Scroller
All Packages Class Hierarchy This Package Previous Next Index
Class tea.set.Scroller
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----tea.set.Scroller
- public class Scroller
- extends Panel
- implements Runnable
Scroller is a decorator widget. It attaches scrollbars to a component
for scrolling. If the component implements the Scrollable interface,
the Scroller uses the methods provided by the Scrollable interface
to set the parameter of scrollbars. When user scrolls a scrollbar,
the scrollable component is notified by the setValue() method, and
the scrollable component is responsible for the actual scrolling.
If the component does not implement scrollable, Scroller automatically
control all scrolling of the component display area. The component
is automatically resized to its preferred size, and the Scroller
controls the visible portion of the component.
By default, scrollbars are only attached to the component if necessary.
For scrollable component, scrollbar is deemed necessary for an
orientation if the maximum value is greater than the minimum value.
For non-scrollable components, scrollbar is deemed necessary for
an orientation if the preferred size is greater than the actual
size.
For scrollable components, Scroller calls Scrollable methods to set
scrollbar parameters at initialization time. However, depending
on the implementation of scrollable components, the exact value for
those parameters may not be know when the Scrollable methods are
first called. If this is the case, the scrollable component
should arrange to call the notifyUpdate() method of Scroller when
correct values are available.
Known Bug: AWT Scrollbar is highly buggy. It exhibits different
behaviors in different environment (JDK, Netscape, ...) and
different versions (1.01, 1.02, ...). To make
sure all area are always shown, the scrollbar value may appear to
to too large, which will cause excessive scrolling at the end.
- See Also:
- Scrollable
-
Scroller(Component)
- Attach a Scroller to a component.
-
Scroller(Component, boolean)
- Attach a Scroller to a component.
-
Scroller(Component, boolean, int, int)
- Attach a Scroller to a component.
-
finalize()
- Cleanup and release resource.
-
handleEvent(Event)
- Handle scrolling related events.
-
notifyUpdate()
- This method can be called by the scrolled component to signal a
need to recalculate the scrollbar values.
-
preferredSize()
- Return the preferred size.
-
reshape(int, int, int, int)
- Use reshape as the initialization function.
-
run()
- This thread handles the actual scrolling of component.
Scroller
public Scroller(Component comp)
- Attach a Scroller to a component. Scrollbars are created if
necessary.
- Parameters:
- comp - component to be scrolled.
Scroller
public Scroller(Component comp,
boolean auto)
- Attach a Scroller to a component. If auto is true, the scrollbars
are only created if necessary. Otherwise, scrollbars will be
created regardless of their need.
- Parameters:
- comp - component to be scrolled.
- auto - automatically determine if scrollbar is needed
if true.
Scroller
public Scroller(Component comp,
boolean auto,
int w,
int h)
- Attach a Scroller to a component. If auto is true, the scrollbars
are only created if necessary. Otherwise, scrollbars will be
created regardless of their need. The width and height are
used as the preferred size of the Scroller.
- Parameters:
- comp - component to be scrolled.
- auto - automatically determine if scrollbar is needed
if true.
- w - preferred width.
- h - preferred height.
finalize
public void finalize()
- Cleanup and release resource.
- Overrides:
- finalize in class Object
notifyUpdate
public void notifyUpdate()
- This method can be called by the scrolled component to signal a
need to recalculate the scrollbar values.
reshape
public void reshape(int x,
int y,
int w,
int h)
- Use reshape as the initialization function.
- Parameters:
- x - x coordinate.
- y - y coordinate.
- w - width.
- h - height.
- Overrides:
- reshape in class Component
preferredSize
public Dimension preferredSize()
- Return the preferred size. If the size if passed in constructor,
it will be returned. Otherwise the size will be the preferred
size of its managed component.
- Returns:
- preferred size.
- Overrides:
- preferredSize in class Container
handleEvent
public boolean handleEvent(Event e)
- Handle scrolling related events.
- Parameters:
- e - event object.
- Overrides:
- handleEvent in class Component
run
public synchronized void run()
- This thread handles the actual scrolling of component. There is
a slight delay between the click and actual update introduced to
correct a Java bug.
All Packages Class Hierarchy This Package Previous Next Index