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

Name Method
Background setBackground
BlockIncrement setBlockIncrement
FilterTime setFilterTime
Foreground setForeground
Maximum setMaximum
Minimum setMinimum
Orientation setOrientation
PreferredSize setPreferredSize
UnitIncrement setUnitIncrement
UserData setUserData
Value setValue
VisibleAmount setVisibleAmount

Events

Class Listener Description
JCAdjustmentEvent addAdjustmentListener Posted when the value changes


Variable Index

 o adjustmentListeners
List of JCAdjustmentEvent listeners.
 o decr_arrow
Down/right and up/left arrow buttons.
 o HORIZONTAL
 o incr_arrow
Down/right and up/left arrow buttons.
 o scrolled_window
Parent window.
 o thumb
Scrollbar's thumb.
 o VERTICAL

Constructor Index

 o JCScrollbar()
Constructs a vertical scrollbar.
 o JCScrollbar(int)
Constructs a scrollbar with the specified orientation.
 o JCScrollbar(int, Applet, String)
Creates a scrollbar which reads parameters from the applet's HTML file.
 o JCScrollbar(int, int, int, int, int)
Constructs a scrollbar with an initial orientation, value, page size, and minumum and max values.

Method Index

 o actionPerformed(JCActionEvent)
Scrolls by a line if an arrow key was pressed.
 o addAdjustmentListener(JCAdjustmentListener)
Adds the specified adjustment listener to receive adjustment events.
 o atEnd()
 o getBlockIncrement()
Gets the page increment.
 o getFilterTime()
Gets the FilterTime value.
 o getMaximum()
Gets the maximum value.
 o getMinimum()
Gets the minimum value.
 o getOrientation()
Gets the orientation.
 o getParameters()
Reads the parameter values from the HTML page using the component's applet.
 o getParameters(Applet)
Gets a parameter for this container.
 o getUnitIncrement()
Gets the line increment.
 o getValue()
Gets the current value.
 o getVisible()
Deprecated.
 o getVisibleAmount()
Returns the slider size, in user units
 o isFocusTraversable()
Returns whether this component can be traversed using Tab or Shift-Tab keyboard focus traversal.
 o keyDown(Event, int)
Moves the slider if HOME, END, PGUP, PGDN or an arrow key is hit.
 o layout()
Positions the thumb and arrow buttons.
 o 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.

 o mouseDrag(Event, int, int)
Handles a mouse drag event in the slider.
 o mouseUp(Event, int, int)
Resets the scrollbar state after some other operation.
 o paintInterior(Graphics)
Draws a 1-pixel black border.
 o paintThumb(Graphics)
Paints the thumb.
 o preferredHeight()
Returns BWTEnum.SB_SIZE if this is a horizontal scrollbar; 100 otherwise.
 o preferredWidth()
Returns BWTEnum.SB_SIZE if this is a vertical scrollbar; 100 otherwise.
 o removeAdjustmentListener(JCAdjustmentListener)
Removes the specified adjustment listener so that it no longer receives adjustment events.
 o reshape(int, int, int, int)
Reshapes the Container to the specified bounding box.
 o setBackground(Color)
Sets the background color.
 o setBlockIncrement(int)
Sets the page increment.
 o 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).
 o setForeground(Color)
Sets the foreground color.
 o setLayout(LayoutManager)
Sets the layout manager for this container.
 o setMaximum(int)
Sets the maximum value (default: 100).
 o setMinimum(int)
Sets the minimum value.
 o setOrientation(int)
Sets the orientation.
 o setUnitIncrement(int)
Sets the line increment (default: 10).
 o setValue(int)
Sets the value.
 o setValue(int, boolean)
Sets the value.
 o setValues(int, int, int, int)
Sets the values.
 o setVisibleAmount(int)
Sets the slider size, in user units.

Variables

 o HORIZONTAL
  public final static int HORIZONTAL
 o VERTICAL
  public final static int VERTICAL
 o scrolled_window
  protected transient JCScrolledWindow scrolled_window
Parent window.

 o incr_arrow
  protected JCArrowButton incr_arrow
Down/right and up/left arrow buttons.

 o decr_arrow
  protected JCArrowButton decr_arrow
Down/right and up/left arrow buttons.

 o thumb
  protected ScrollbarThumb thumb
Scrollbar's thumb.

 o adjustmentListeners
  protected JCVector adjustmentListeners
List of JCAdjustmentEvent listeners.

Constructors

 o JCScrollbar
  public JCScrollbar()
Constructs a vertical scrollbar.

 o JCScrollbar
  public JCScrollbar(int dir)
Constructs a scrollbar with the specified orientation.

Parameters:
dir - either HORIZONTAL or VERTICAL
 o 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
 o 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

Methods

 o 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
 o getParameters
  public void getParameters(Applet applet)
Gets a parameter for this container.

Overrides:
getParameters in class JCContainer
 o isFocusTraversable
  public boolean isFocusTraversable()
Returns whether this component can be traversed using Tab or Shift-Tab keyboard focus traversal.

Overrides:
isFocusTraversable in class Component
 o getOrientation
  public int getOrientation()
Gets the orientation.

 o 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
 o 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
 o 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
 o setValue
  public synchronized void setValue(int value,
                                    boolean notify)
Sets the value.

Parameters:
notify - if true, an JCAdjustmentEvent is posted.
See Also:
addAdjustmentListener
 o getMinimum
  public int getMinimum()
Gets the minimum value.

See Also:
setMinimum
 o setMinimum
  public synchronized void setMinimum(int v)
Sets the minimum value.

See Also:
setValues
 o getMaximum
  public int getMaximum()
Gets the maximum value.

See Also:
setMaximum
 o setMaximum
  public synchronized void setMaximum(int v)
Sets the maximum value (default: 100).

See Also:
setValues
 o getVisibleAmount
  public int getVisibleAmount()
Returns the slider size, in user units

See Also:
setVisibleAmount
 o getVisible
  public int getVisible()
Note: getVisible() is deprecated.

See Also:
getVisibleAmount
 o setVisibleAmount
  public synchronized void setVisibleAmount(int v)
Sets the slider size, in user units.

See Also:
setValues
 o 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.

 o getUnitIncrement
  public int getUnitIncrement()
Gets the line increment.

 o 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).

 o getBlockIncrement
  public int getBlockIncrement()
Gets the page increment.

 o 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
 o atEnd
  public boolean atEnd()
Returns:
true if slider is currently at min or max value
 o getFilterTime
  public long getFilterTime()
Gets the FilterTime value.

See Also:
setFilterTime
 o 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

 o preferredWidth
  protected int preferredWidth()
Returns BWTEnum.SB_SIZE if this is a vertical scrollbar; 100 otherwise.

Overrides:
preferredWidth in class JCContainer
 o preferredHeight
  protected int preferredHeight()
Returns BWTEnum.SB_SIZE if this is a horizontal scrollbar; 100 otherwise.

Overrides:
preferredHeight in class JCContainer
 o addAdjustmentListener
  public void addAdjustmentListener(JCAdjustmentListener l)
Adds the specified adjustment listener to receive adjustment events.

See Also:
JCAdjustmentEvent
 o removeAdjustmentListener
  public void removeAdjustmentListener(JCAdjustmentListener l)
Removes the specified adjustment listener so that it no longer receives adjustment events.

 o actionPerformed
  public void actionPerformed(JCActionEvent ev)
Scrolls by a line if an arrow key was pressed.

 o mouseUp
  public boolean mouseUp(Event ev,
                         int x,
                         int y)
Resets the scrollbar state after some other operation.

Overrides:
mouseUp in class Component
 o 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
 o mouseDrag
  public boolean mouseDrag(Event ev,
                           int x,
                           int y)
Handles a mouse drag event in the slider.

Overrides:
mouseDrag in class Component
 o 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
 o 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
 o layout
  public synchronized void layout()
Positions the thumb and arrow buttons.

Overrides:
layout in class Container
 o paintThumb
  protected void paintThumb(Graphics gc)
Paints the thumb.

 o paintInterior
  public void paintInterior(Graphics gc)
Draws a 1-pixel black border.

Overrides:
paintInterior in class JCContainer
 o setForeground
  public synchronized void setForeground(Color c)
Sets the foreground color.

Overrides:
setForeground in class Component
 o setBackground
  public synchronized void setBackground(Color c)
Sets the background color.

Overrides:
setBackground in class Component
 o 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