All Packages Class Hierarchy This Package Previous Next Index
Class COM.taligent.widget.Scroller
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Canvas
|
+----COM.taligent.widget.Scroller
- public class Scroller
- extends Canvas
- implements Adjustable, Runnable, KeyListener, MouseListener, MouseMotionListener
A custom JDK 1.1 scrollbar. The Scroller class behaves
exactly like AWT scrollbars.
You can change the appearance of the scrollbar by
extending Scroller and overriding paintBackground,
paintButton, and paintHandle.
- Version:
- 1.0 (JDK 1.1)
- Author:
- Andy Clark, Taligent Inc.
-
DEFAULT_ORIENTATION
- Default orientation (VERTICAL).
-
DEFAULT_SCROLL_DELAY
- Default scroll delay between successive scrolls (125 ms).
-
DOWN
- The "down" button (internal use only).
-
HORIZONTAL
- Horizontal orientation.
-
LEFT
- The "left" button (internal use only).
-
RIGHT
- The "right" button (internal use only).
-
serialVersionUID
-
-
UP
- The "up" button (internal use only).
-
VERTICAL
- Vertical orientation.
-
Scroller()
- Constructs a scrollbar with the default orientation.
-
Scroller(int)
- Constructs a scrollbar with the specified orientation.
-
Scroller(int, int, int, int, int)
- Constructs scrollbar with specified values.
-
addAdjustmentListener(AdjustmentListener)
- Adds an item listener.
-
getBlockIncrement()
- Returns the current block increment value.
-
getLineIncrement()
- Returns current unit increment.
Deprecated.
-
getMaximum()
- Returns the current maximum value of this scrollbar.
-
getMinimum()
- Returns the current minimum value of this scrollbar.
-
getMinimumSize()
- Returns an arbitrary minimum size of the scrollbar.
-
getOrientation()
- Returns the current orientation of this scrollbar.
-
getPageIncrement()
- Returns the current block increment.
Deprecated.
-
getPreferredSize()
- Returns the preferred size (minimum size) of the component.
-
getScrollDelay()
- Returns the current scroll delay.
-
getUnitIncrement()
- Returns the current unit increment value.
-
getValue()
- Returns the current value of this scrollbar.
-
getVisibleAmount()
- Returns how many elements are currently visible.
-
init()
- Initialize transient data.
-
keyPressed(KeyEvent)
- Key pressed.
-
keyReleased(KeyEvent)
- Key released.
-
keyTyped(KeyEvent)
- Key typed.
-
minimumSize()
- The method minimumSize doesn't call getMinimumSize
like it should.
Deprecated.
-
mouseClicked(MouseEvent)
- Mouse clicked.
-
mouseDragged(MouseEvent)
- Mouse dragged.
-
mouseEntered(MouseEvent)
- Mouse entered component.
-
mouseExited(MouseEvent)
- Mouse exited component.
-
mouseMoved(MouseEvent)
- Mouse moved.
-
mousePressed(MouseEvent)
- Mouse pressed.
-
mouseReleased(MouseEvent)
- Mouse released.
-
paint(Graphics)
- Paint the scrollbar with the current settings.
-
paintBackground(Graphics)
- Paints the background of the scrollbar.
-
paintButton(Graphics, int)
- Paints a button.
-
paintHandle(Graphics)
- Paints the handle.
-
preferredSize()
- The method preferredSize doesn't call getPreferredSize
like it should.
Deprecated.
-
removeAdjustmentListener(AdjustmentListener)
- Removes an item listener.
-
run()
- Allows continuation of scrolling when mouse button
stays down on scrolls.
-
setBackground(Color)
- Invalidate background buffer if color changed.
-
setBlockIncrement(int)
- Sets how many to increment/decrement by when the user
presses in the scrollbar region between the unit
increment buttons and the scroll handle.
-
setBounds(int, int, int, int)
- Sets the component's location and size.
-
setForeground(Color)
- Invalidate background buffer if color changed.
-
setLineIncrement(int)
- Sets how many units to increment/decrement by when the
user pushes the up/down (or left/right) scroll buttons.
Deprecated.
-
setMaximum(int)
- Sets the maximum value of this scrollbar.
-
setMinimum(int)
- Sets the minimum value of this scrollbar.
-
setOrientation(int)
- Sets the orientation of the scrollbar.
-
setPageIncrement(int)
- Sets how many to increment/decrement by when the user
presses in the scrollbar region between the unit
increment buttons and the scroll handle.
Deprecated.
-
setScrollDelay(int)
- Sets the delay between successive scrolls.
-
setUnitIncrement(int)
- Sets how many units to increment/decrement by when the
user pushes the up/down (or left/right) scroll buttons.
-
setValue(int)
- Sets the value of this scrollbar.
-
setValues(int, int, int, int)
- Sets all of the values of this scrollbar.
-
setVisibleAmount(int)
- Sets how many elements are currently visible.
-
toString()
- Returns a string representation of this component.
-
update(Graphics)
- public void setSize(int width, int height) {
if (fOrientation == HORIZONTAL) {
if (height > WIDTH)
height = WIDTH;
}
else {
if (width > WIDTH)
width = WIDTH;
}
super.setSize(width, height);
}
/** Don't clear area -- not needed.
serialVersionUID
public static final long serialVersionUID
VERTICAL
public static final int VERTICAL
- Vertical orientation.
HORIZONTAL
public static final int HORIZONTAL
- Horizontal orientation.
DEFAULT_ORIENTATION
public static final int DEFAULT_ORIENTATION
- Default orientation (VERTICAL).
DEFAULT_SCROLL_DELAY
public static final int DEFAULT_SCROLL_DELAY
- Default scroll delay between successive scrolls (125 ms).
UP
protected static final int UP
- The "up" button (internal use only).
DOWN
protected static final int DOWN
- The "down" button (internal use only).
LEFT
protected static final int LEFT
- The "left" button (internal use only).
RIGHT
protected static final int RIGHT
- The "right" button (internal use only).
Scroller
public Scroller()
- Constructs a scrollbar with the default orientation.
Scroller
public Scroller(int orientation)
- Constructs a scrollbar with the specified orientation.
Scroller
public Scroller(int orientation,
int value,
int visible,
int min,
int max)
- Constructs scrollbar with specified values.
init
public void init()
- Initialize transient data.
setBackground
public void setBackground(Color color)
- Invalidate background buffer if color changed.
- Overrides:
- setBackground in class Component
setForeground
public void setForeground(Color color)
- Invalidate background buffer if color changed.
- Overrides:
- setForeground in class Component
run
public void run()
- Allows continuation of scrolling when mouse button
stays down on scrolls.
setScrollDelay
public void setScrollDelay(int delay)
- Sets the delay between successive scrolls.
- Parameters:
- delay - The new delay time, in milliseconds.
- See Also:
- DEFAULT_SCROLL_DELAY, getScrollDelay
getScrollDelay
public int getScrollDelay()
- Returns the current scroll delay.
- See Also:
- setScrollDelay
addAdjustmentListener
public void addAdjustmentListener(AdjustmentListener listener)
- Adds an item listener.
removeAdjustmentListener
public void removeAdjustmentListener(AdjustmentListener listener)
- Removes an item listener.
setOrientation
public void setOrientation(int orientation)
- Sets the orientation of the scrollbar.
- Parameters:
- orientation - The new orientation An invalid
orientation is considered to be
HORIZONTAL.
- See Also:
- VERTICAL, HORIZONTAL, getOrientation
getOrientation
public int getOrientation()
- Returns the current orientation of this scrollbar.
- See Also:
- setOrientation
setValue
public void setValue(int value)
- Sets the value of this scrollbar.
- Parameters:
- value - The new value. The new value is
adjusted automatically if the value is less
than or greater than the minimum and maximum
values, respectively.
- See Also:
- setValues, getValue
getValue
public int getValue()
- Returns the current value of this scrollbar.
- See Also:
- setValue
setValues
public void setValues(int value,
int visible,
int min,
int max)
- Sets all of the values of this scrollbar. The values are
set in the following order: min, max, value, and visible.
This is so that the value can be checked against the new
minimum and maximum values.
- Parameters:
- value - The new value.
- visible - The visible value.
- min - The minimum value of the scrollbar.
- max - The maximum value of the scrollbar.
- See Also:
- setValue, getValue
setMinimum
public void setMinimum(int minimum)
- Sets the minimum value of this scrollbar.
- Parameters:
- minimum - The new minimum value. The minimum
value is automatically adjusted if
the new value is greater than the
scrollbar's maximum value.
- See Also:
- setMaximum, getMinimum
getMinimum
public int getMinimum()
- Returns the current minimum value of this scrollbar.
- See Also:
- setMinimum
setMaximum
public void setMaximum(int maximum)
- Sets the maximum value of this scrollbar.
- Parameters:
- maximum - The new maximum value. The maximum
value is automatically adjusted if
the new value is less than the
scrollbar's minimum value.
- See Also:
- setMinimum, getMaximum
getMaximum
public int getMaximum()
- Returns the current maximum value of this scrollbar.
- See Also:
- setMaximum
setLineIncrement
public void setLineIncrement(int increment)
- Note: setLineIncrement() is deprecated.
Use setUnitIncrement(int).
- Sets how many units to increment/decrement by when the
user pushes the up/down (or left/right) scroll buttons.
getLineIncrement
public int getLineIncrement()
- Note: getLineIncrement() is deprecated.
Use getUnitIncrement().
- Returns current unit increment.
setUnitIncrement
public void setUnitIncrement(int increment)
- Sets how many units to increment/decrement by when the
user pushes the up/down (or left/right) scroll buttons.
- Parameters:
- increment - The new unit increment value. No error
checking is done on the increment. In
other words, you could have the scrollbar
move down when they hit the up button
by settings the increment to a negative
value.
- See Also:
- getUnitIncrement, setBlockIncrement
getUnitIncrement
public int getUnitIncrement()
- Returns the current unit increment value.
- See Also:
- setUnitIncrement
setPageIncrement
public void setPageIncrement(int increment)
- Note: setPageIncrement() is deprecated.
Use setBlockIncrement(int).
- Sets how many to increment/decrement by when the user
presses in the scrollbar region between the unit
increment buttons and the scroll handle.
getPageIncrement
public int getPageIncrement()
- Note: getPageIncrement() is deprecated.
Use getBlockIncrement().
- Returns the current block increment.
setBlockIncrement
public void setBlockIncrement(int increment)
- Sets how many to increment/decrement by when the user
presses in the scrollbar region between the unit
increment buttons and the scroll handle.
- Parameters:
- increment - The new block increment value.
- See Also:
- getBlockIncrement, setUnitIncrement
getBlockIncrement
public int getBlockIncrement()
- Returns the current block increment value.
- See Also:
- setBlockIncrement
setVisibleAmount
public void setVisibleAmount(int visible)
- Sets how many elements are currently visible.
- Parameters:
- visible - Number of visible elements.
- See Also:
- getVisibleAmount
getVisibleAmount
public int getVisibleAmount()
- Returns how many elements are currently visible.
- See Also:
- setVisibleAmount
preferredSize
public Dimension preferredSize()
- Note: preferredSize() is deprecated.
Use getPreferredSize().
- The method preferredSize doesn't call getPreferredSize
like it should. Once preferredSize is fully deprecated,
this will go away.
- Overrides:
- preferredSize in class Component
getPreferredSize
public Dimension getPreferredSize()
- Returns the preferred size (minimum size) of the component.
- Overrides:
- getPreferredSize in class Component
minimumSize
public Dimension minimumSize()
- Note: minimumSize() is deprecated.
Use getMinimumSize().
- The method minimumSize doesn't call getMinimumSize
like it should. Once mimimumSize is fully deprecated,
this will go away.
- Overrides:
- minimumSize in class Component
getMinimumSize
public Dimension getMinimumSize()
- Returns an arbitrary minimum size of the scrollbar.
- Overrides:
- getMinimumSize in class Component
setBounds
public void setBounds(int x,
int y,
int w,
int h)
- Sets the component's location and size.
- Overrides:
- setBounds in class Component
update
public void update(Graphics g)
- public void setSize(int width, int height) {
if (fOrientation == HORIZONTAL) {
if (height > WIDTH)
height = WIDTH;
}
else {
if (width > WIDTH)
width = WIDTH;
}
super.setSize(width, height);
}
/** Don't clear area -- not needed.
- Overrides:
- update in class Component
paint
public void paint(Graphics graphics)
- Paint the scrollbar with the current settings.
- Parameters:
- g - The graphics context.
- Overrides:
- paint in class Canvas
paintBackground
public void paintBackground(Graphics graphics)
- Paints the background of the scrollbar. This is the
area used between the scroll buttons and the handle.
You can override this method to alter the appearance
of the scrollbar.
- Parameters:
- g - The graphics context.
- See Also:
- paintButton, paintHandle
paintButton
public void paintButton(Graphics g,
int type)
- Paints a button. This method can be overridden to
alter the appearance of the scrollbar.
- Parameters:
- g - The graphics context.
- type - Which button to draw.
- See Also:
- UP, DOWN, LEFT, RIGHT, paintBackground, paintHandle
paintHandle
public void paintHandle(Graphics g)
- Paints the handle. This method can be overridden to
alter the appearance of the scrollbar.
- Parameters:
- g - The graphics context.
- See Also:
- paintBackground, paintButton
keyTyped
public void keyTyped(KeyEvent evt)
- Key typed.
keyPressed
public void keyPressed(KeyEvent evt)
- Key pressed.
keyReleased
public void keyReleased(KeyEvent evt)
- Key released.
mouseClicked
public void mouseClicked(MouseEvent evt)
- Mouse clicked.
mousePressed
public void mousePressed(MouseEvent evt)
- Mouse pressed.
mouseReleased
public void mouseReleased(MouseEvent evt)
- Mouse released.
mouseEntered
public void mouseEntered(MouseEvent evt)
- Mouse entered component.
mouseExited
public void mouseExited(MouseEvent evt)
- Mouse exited component.
mouseDragged
public void mouseDragged(MouseEvent evt)
- Mouse dragged.
mouseMoved
public void mouseMoved(MouseEvent evt)
- Mouse moved.
toString
public String toString()
- Returns a string representation of this component.
- Overrides:
- toString in class Component
All Packages Class Hierarchy This Package Previous Next Index