All Packages Class Hierarchy This Package Previous Next Index
Class jclass.bwt.JCScrollbar
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----jclass.bwt.JCContainer
|
+----jclass.bwt.JCScrollbar
- public class JCScrollbar
- extends JCContainer
- implements JCAdjustable, JCActionListener
The JCScrollbar component allows the user to view data that is too large to
be displayed all at once. Scrollbars are usually located inside a
JCScrolledWindow
and adjacent to the component that contains the data to be
viewed. When the user interacts with the scrollbar, the data within the other
component scrolls.
Behavior
The scrollbar consists of two JCArrowButtons at either end, and a rectangular
area called a thumb within it. The data is scrolled by clicking a button,
clicking to either side of the thumb, or dragging the thumb. Clicking
to either side of the thumb with the CONTROL key pressed will cause the
thumb to move to the beginning or end.
Hitting PAGE-UP or PAGE-DOWN will scroll up
or down by a page. Hitting HOME or END will scroll to the beginning or end.
Properties
Events
-
adjustmentListeners
- List of JCAdjustmentEvent listeners.
-
decr_arrow
- Down/right and up/left arrow buttons.
-
HORIZONTAL
-
-
incr_arrow
- Down/right and up/left arrow buttons.
-
scrolled_window
- Parent window.
-
thumb
- Scrollbar's thumb.
-
VERTICAL
-
-
JCScrollbar()
- Constructs a vertical scrollbar.
-
JCScrollbar(int)
- Constructs a scrollbar with the specified orientation.
-
JCScrollbar(int, Applet, String)
- Creates a scrollbar which reads parameters from the applet's HTML file.
-
JCScrollbar(int, int, int, int, int)
- Constructs a scrollbar with an initial orientation,
value, page size, and minumum and max values.
-
actionPerformed(JCActionEvent)
- Scrolls by a line if an arrow key was pressed.
-
addAdjustmentListener(JCAdjustmentListener)
- Adds the specified adjustment listener to receive adjustment events.
-
atEnd()
-
-
getBlockIncrement()
- Gets the page increment.
-
getFilterTime()
- Gets the FilterTime value.
-
getMaximum()
- Gets the maximum value.
-
getMinimum()
- Gets the minimum value.
-
getOrientation()
- Gets the orientation.
-
getParameters()
- Reads the parameter values from the HTML page using the component's applet.
-
getParameters(Applet)
- Gets a parameter for this container.
-
getUnitIncrement()
- Gets the line increment.
-
getValue()
- Gets the current value.
-
getVisible()
-
Deprecated.
-
getVisibleAmount()
- Returns the slider size, in user units
-
isFocusTraversable()
- Returns whether this component can be traversed using
Tab or Shift-Tab keyboard focus traversal.
-
keyDown(Event, int)
- Moves the slider if HOME, END, PGUP, PGDN or an arrow key is hit.
-
layout()
- Positions the thumb and arrow buttons.
-
mouseDown(Event, int, int)
- If an arrow button is pressed, the slider will move by one line.
If the trough is clicked with the CTRL key down, the slider will move to the beginning or end.
If the trough is clicked, the slider will move by one page.
-
mouseDrag(Event, int, int)
- Handles a mouse drag event in the slider.
-
mouseUp(Event, int, int)
- Resets the scrollbar state after some other operation.
-
paintInterior(Graphics)
- Draws a 1-pixel black border.
-
paintThumb(Graphics)
- Paints the thumb.
-
preferredHeight()
- Returns BWTEnum.SB_SIZE if this is a horizontal scrollbar; 100 otherwise.
-
preferredWidth()
- Returns BWTEnum.SB_SIZE if this is a vertical scrollbar; 100 otherwise.
-
removeAdjustmentListener(JCAdjustmentListener)
- Removes the specified adjustment listener so that it no longer
receives adjustment events.
-
reshape(int, int, int, int)
- Reshapes the Container to the specified bounding box.
-
setBackground(Color)
-
Sets the background color.
-
setBlockIncrement(int)
- Sets the page increment.
-
setFilterTime(long)
- If 2 mouse drag events are received within this interval,
the 2nd is not reported (ie no events are posted) (default: 0 ms).
-
setForeground(Color)
-
Sets the foreground color.
-
setLayout(LayoutManager)
-
Sets the layout manager for this container.
-
setMaximum(int)
- Sets the maximum value (default: 100).
-
setMinimum(int)
- Sets the minimum value.
-
setOrientation(int)
- Sets the orientation.
-
setUnitIncrement(int)
- Sets the line increment (default: 10).
-
setValue(int)
- Sets the value.
-
setValue(int, boolean)
- Sets the value.
-
setValues(int, int, int, int)
- Sets the values.
-
setVisibleAmount(int)
- Sets the slider size, in user units.
HORIZONTAL
public static final int HORIZONTAL
VERTICAL
public static final int VERTICAL
scrolled_window
protected transient JCScrolledWindow scrolled_window
- Parent window.
incr_arrow
protected JCArrowButton incr_arrow
- Down/right and up/left arrow buttons.
decr_arrow
protected JCArrowButton decr_arrow
- Down/right and up/left arrow buttons.
thumb
protected ScrollbarThumb thumb
- Scrollbar's thumb.
adjustmentListeners
protected JCVector adjustmentListeners
- List of JCAdjustmentEvent listeners.
JCScrollbar
public JCScrollbar()
- Constructs a vertical scrollbar.
JCScrollbar
public JCScrollbar(int dir)
- Constructs a scrollbar with the specified orientation.
- Parameters:
- dir - either HORIZONTAL or VERTICAL
JCScrollbar
public JCScrollbar(int dir,
Applet applet,
String name)
- Creates a scrollbar which reads parameters from the applet's HTML file.
- Parameters:
- dir - either HORIZONTAL or VERTICAL
- applet - the applet whose PARAM tags are to be read
- name - if this is not null, only parameters preceded by this name are read
- See Also:
- getParameter
JCScrollbar
public JCScrollbar(int dir,
int value,
int visible,
int min,
int max)
- Constructs a scrollbar with an initial orientation,
value, page size, and minumum and max values.
- Parameters:
- dir - either HORIZONTAL or VERTICAL
- value - the scrollbar's value
- visible - the size of the visible portion of the
scrollable area. The scrollbar will use this value when paging up
or down by a page.
- min - the min value
- max - the max value
getParameters
protected void getParameters()
- Reads the parameter values from the HTML page using the component's applet.
The values will override those previously set.
- Overrides:
- getParameters in class JCContainer
getParameters
public void getParameters(Applet applet)
- Gets a parameter for this container.
- Overrides:
- getParameters in class JCContainer
isFocusTraversable
public boolean isFocusTraversable()
- Returns whether this component can be traversed using
Tab or Shift-Tab keyboard focus traversal.
- Overrides:
- isFocusTraversable in class Component
getOrientation
public int getOrientation()
- Gets the orientation.
setOrientation
public synchronized void setOrientation(int dir)
- Sets the orientation. This must be called before the scollbar is visible
(ie before it is added to its parent).
- Parameters:
- dir - either HORIZONTAL or VERTICAL
- Throws: IllegalArgumentException
- If an invalid value is set
getValue
public synchronized int getValue()
- Gets the current value. This will be between the minimum value and the
maximum value minus the slider size.
- See Also:
- getMinimum, getMaximum
setValue
public synchronized void setValue(int value)
- Sets the value.
- Parameters:
- value - the new value. If this value is
below the current minimum or above the current maximum, it becomes the
new one of those values, respectively.
- See Also:
- getValue
setValue
public synchronized void setValue(int value,
boolean notify)
- Sets the value.
- Parameters:
- notify - if true, an JCAdjustmentEvent is posted.
- See Also:
- addAdjustmentListener
getMinimum
public int getMinimum()
- Gets the minimum value.
- See Also:
- setMinimum
setMinimum
public synchronized void setMinimum(int v)
- Sets the minimum value.
- See Also:
- setValues
getMaximum
public int getMaximum()
- Gets the maximum value.
- See Also:
- setMaximum
setMaximum
public synchronized void setMaximum(int v)
- Sets the maximum value (default: 100).
- See Also:
- setValues
getVisibleAmount
public int getVisibleAmount()
- Returns the slider size, in user units
- See Also:
- setVisibleAmount
getVisible
public int getVisible()
- Note: getVisible() is deprecated.
- See Also:
- getVisibleAmount
setVisibleAmount
public synchronized void setVisibleAmount(int v)
- Sets the slider size, in user units.
- See Also:
- setValues
setUnitIncrement
public void setUnitIncrement(int v)
- Sets the line increment (default: 10). This is the amount that is
scrolled up or down when the user clicks the arrow buttons.
getUnitIncrement
public int getUnitIncrement()
- Gets the line increment.
setBlockIncrement
public void setBlockIncrement(int v)
- Sets the page increment. This is the amount that will
be scrolled up or down when the user clicks above/below the slider
(default: slider size).
getBlockIncrement
public int getBlockIncrement()
- Gets the page increment.
setValues
public synchronized void setValues(int value,
int visible,
int min,
int max)
- Sets the values.
- Parameters:
- value - the scrollbar's value
- visible - the amount visible per page (the slider size).
The page increment is also set to this value.
- min - the minimum value of the scrollbar
- max - the maximum value of the scrollbar
- See Also:
- setBlockIncrement
atEnd
public boolean atEnd()
- Returns:
- true if slider is currently at min or max value
getFilterTime
public long getFilterTime()
- Gets the FilterTime value.
- See Also:
- setFilterTime
setFilterTime
public void setFilterTime(long t)
- If 2 mouse drag events are received within this interval,
the 2nd is not reported (ie no events are posted) (default: 0 ms).
To specify that no events are to be reported until the user releases the
mouse, set this value to BWTEnum.MAXINT.
HTML param name/value: "FilterTime"/int
preferredWidth
protected int preferredWidth()
- Returns BWTEnum.SB_SIZE if this is a vertical scrollbar; 100 otherwise.
- Overrides:
- preferredWidth in class JCContainer
preferredHeight
protected int preferredHeight()
- Returns BWTEnum.SB_SIZE if this is a horizontal scrollbar; 100 otherwise.
- Overrides:
- preferredHeight in class JCContainer
addAdjustmentListener
public void addAdjustmentListener(JCAdjustmentListener l)
- Adds the specified adjustment listener to receive adjustment events.
- See Also:
- JCAdjustmentEvent
removeAdjustmentListener
public void removeAdjustmentListener(JCAdjustmentListener l)
- Removes the specified adjustment listener so that it no longer
receives adjustment events.
actionPerformed
public void actionPerformed(JCActionEvent ev)
- Scrolls by a line if an arrow key was pressed.
mouseUp
public boolean mouseUp(Event ev,
int x,
int y)
- Resets the scrollbar state after some other operation.
- Overrides:
- mouseUp in class Component
mouseDown
public boolean mouseDown(Event ev,
int x,
int y)
- If an arrow button is pressed, the slider will move by one line.
If the trough is clicked with the CTRL key down, the slider will move to the beginning or end.
If the trough is clicked, the slider will move by one page.
- Overrides:
- mouseDown in class Component
mouseDrag
public boolean mouseDrag(Event ev,
int x,
int y)
- Handles a mouse drag event in the slider.
- Overrides:
- mouseDrag in class Component
keyDown
public boolean keyDown(Event ev,
int key)
- Moves the slider if HOME, END, PGUP, PGDN or an arrow key is hit.
- Overrides:
- keyDown in class Component
reshape
public synchronized void reshape(int x,
int y,
int w,
int h)
- Reshapes the Container to the specified bounding box.
- Overrides:
- reshape in class JCContainer
layout
public synchronized void layout()
- Positions the thumb and arrow buttons.
- Overrides:
- layout in class Container
paintThumb
protected void paintThumb(Graphics gc)
- Paints the thumb.
paintInterior
public void paintInterior(Graphics gc)
- Draws a 1-pixel black border.
- Overrides:
- paintInterior in class JCContainer
setForeground
public synchronized void setForeground(Color c)
- Sets the foreground color.
- Overrides:
- setForeground in class Component
setBackground
public synchronized void setBackground(Color c)
- Sets the background color.
- Overrides:
- setBackground in class Component
setLayout
public final void setLayout(LayoutManager mgr)
- Sets the layout manager for this container. This method is
overridden to prevent the layout mgr from being set.
- Overrides:
- setLayout in class Container
All Packages Class Hierarchy This Package Previous Next Index