All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jclass.bwt.JCSlider

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----jclass.bwt.JCContainer
                                   |
                                   +----jclass.bwt.JCSlider

public class JCSlider
extends JCContainer
implements JCAdjustable
A JCSlider is a subclass of JCScrollbar which is used by an application to indicate a value from within a range of values. It allows the user to input or modify a value from the same range.

A Slider has an elongated rectangular region similar to a ScrollBar. A thumb inside this region indicates the current value along it. The user can also modify the slider's value by moving the slider within the rectangular region of the Scale. A slider can also include labels located at either end.

Properties

UnitIncrement
Name Method
AutoTick setAutoTick
Background setBackground
BlockIncrement setBlockIncrement
Foreground setForeground
Maximum setMaximum
Minimum setMinimum
MaximumLabel setMaximumLabel
MinimumLabel setMinimumLabel
NumTicks setNumTicks
Orientation setOrientation
PreferredSize setPreferredSize
ThumbSize setThumbSize
setBlockIncrement
UserData setUserData
Value setValue

Events

Class Listener Description
JCAdjustmentEvent addAdjustmentListener Posted when the value changes


Variable Index

 o adjustmentListeners
List of JCAdjustmentEvent listeners.
 o HORIZONTAL
 o thumb
Scrollbar's thumb.
 o VERTICAL

Constructor Index

 o JCSlider()
Creates a horizontal slider.
 o JCSlider(int)
Constructs a slider with the specified orientation.
 o JCSlider(int, Applet, String)
Creates a slider which reads parameters from the applet's HTML file.
 o JCSlider(int, int, int, int)
Constructs a slider with an initial orientation, value, and minimum and maximum values.

Method Index

 o addAdjustmentListener(JCAdjustmentListener)
Adds the specified adjustment listener to receive adjustment events.
 o check(int)
 o dragging()
 o drawTicks(Graphics, int)
Draws the tick marks.
 o getAutoTick()
Gets the AutoTick value.
 o getBlockIncrement()
Gets the page increment.
 o getMaximum()
Gets the maximum value.
 o getMaximumLabel()
Gets the MaximumLabel value.
 o getMaximumLabelString()
Gets the MaximumLabel value.
 o getMinimum()
Gets the minimum value.
 o getMinimumLabel()
Gets the MinimumLabel value.
 o getMinimumLabelString()
Gets the MinimumLabel value.
 o getNumTicks()
Returns the NumTicks value.
 o getOrientation()
Gets the orientation.
 o getParameters()
Reads the parameter values from the HTML page using the component's applet.
 o getThumbSize()
Gets the thumb's size.
 o getUnitIncrement()
Gets the line increment.
 o getValue()
Gets the current value.
 o getVisibleAmount()
Returns the thumb size, in user units
 o keyDown(Event, int)
Moves the slider if HOME, END, PGUP, PGDN or an arrow key is hit.
 o layout()
 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 moveThumb()
Moves the slider.
 o paintInterior(Graphics)
Draws the trough and thumb.
 o paintThumb(Graphics)
Paints the thumb.
 o preferredHeight()
Gets the subclass' preferred height (default: 100).
 o preferredWidth()
Gets the subclass' preferred width (default: 100).
 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 resizeThumb(int, int)
Disallows resizing the slider.
 o setAutoTick(boolean)
If true (default), a tick mark is drawn at each page increment.
 o setBackground(Color)
Sets the background color.
 o setBlockIncrement(int)
Sets the page increment.
 o setLayout(LayoutManager)
Sets the layout manager for this container.
 o setMaximum(int)
Sets the maximum value (default: 100).
 o setMaximumLabel(JCLabel)
Sets the label to be displayed at the slider's maximum end (The bottom or right, depending on the orientation).
 o setMaximumLabelString(String)
Sets the label to be displayed at the slider's maximum end (the bottom or right, depending on the orientation).
 o setMinimum(int)
Sets the minimum value.
 o setMinimumLabel(JCLabel)
Sets the label to be displayed at the slider's minimum end (the top or left, depending on the orientation).
 o setMinimumLabelString(String)
Sets the label to be displayed at the slider's minimum end (the top or left, depending on the orientation).
 o setNumTicks(int)
Sets the number of tick marks to be displayed (default: 0).
 o setOrientation(int)
Sets the orientation.
 o setThumbSize(Dimension)
Sets the thumb's size (default: 21x11 for a vertical slider, 11x21 for a horizontal slider).
 o setUnitIncrement(int)
Sets the line increment (default: BlockIncrement value).
 o setValue(int)
Sets the value.
 o setValue(int, boolean)
Sets the value.
 o setValues(int, int, int)
Sets the values.
 o setVisibleAmount(int)
Sets the thumb size, in user units.
 o toPixels(int)
Converts from scrollbar scale to screen pixels.
 o toValue(int)
Converts from screen pixels to scrollbar scale.

Variables

 o HORIZONTAL
 public static final int HORIZONTAL
 o VERTICAL
 public static final int VERTICAL
 o thumb
 protected ScrollbarThumb thumb
Scrollbar's thumb.

 o adjustmentListeners
 protected JCVector adjustmentListeners
List of JCAdjustmentEvent listeners.

Constructors

 o JCSlider
 public JCSlider()
Creates a horizontal slider. No parameters are read from an HTML file

 o JCSlider
 public JCSlider(int dir)
Constructs a slider with the specified orientation.

Parameters:
dir - either HORIZONTAL or VERTICAL
Throws: IllegalArgumentException
when an illegal orientation is given.
 o JCSlider
 public JCSlider(int dir,
                 int value,
                 int min,
                 int max)
Constructs a slider with an initial orientation, value, and minimum and maximum values.

Parameters:
dir - either HORIZONTAL or VERTICAL
value - the scrollbar's value
min - the min value
max - the max value
 o JCSlider
 public JCSlider(int dir,
                 Applet applet,
                 String name)
Creates a slider 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

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 setValues
 public synchronized void setValues(int value,
                                    int min,
                                    int max)
Sets the values.

Parameters:
value - the slider's value The page increment this is also set to this value.
min - the minimum value of the slider
max - the maximum value of the slider
 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 scrollbar 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 check
 protected int check(int value)
 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 setMaximum
 public synchronized void setMaximum(int v)
Sets the maximum value (default: 100).

See Also:
setValues
 o getBlockIncrement
 public int getBlockIncrement()
Gets the page increment.

 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 dragging
 public boolean dragging()
Returns:
true if the user is currently dragging the scrollbar's thumb
 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 moveThumb
 protected void moveThumb()
Moves the slider.

 o paintThumb
 protected void paintThumb(Graphics gc)
Paints the thumb.

 o toPixels
 protected int toPixels(int value)
Converts from scrollbar scale to screen pixels.

 o toValue
 protected int toValue(int value)
Converts from screen pixels to scrollbar scale.

 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
 o getMaximum
 public int getMaximum()
Gets the maximum value.

 o getThumbSize
 public Dimension getThumbSize()
Gets the thumb's size.

See Also:
setThumbSize
 o setThumbSize
 public void setThumbSize(Dimension d)
Sets the thumb's size (default: 21x11 for a vertical slider, 11x21 for a horizontal slider).

 o setUnitIncrement
 public void setUnitIncrement(int v)
Sets the line increment (default: BlockIncrement value). This is the amount that the thumb moves when the user presses an arrow key.

See Also:
setBlockIncrement
 o getUnitIncrement
 public int getUnitIncrement()
Gets the line increment.

 o getVisibleAmount
 public int getVisibleAmount()
Returns the thumb size, in user units

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

 o setBlockIncrement
 public void setBlockIncrement(int v)
Sets the page increment. This is the amount that the thumb will move when the user clicks to either side of it (default: 10).

 o getAutoTick
 public boolean getAutoTick()
Gets the AutoTick value.

See Also:
setAutoTick
 o setAutoTick
 public void setAutoTick(boolean v)
If true (default), a tick mark is drawn at each page increment. This value is ignored if NumTicks is non-zero.

See Also:
setNumTicks
 o getNumTicks
 public int getNumTicks()
Returns the NumTicks value.

See Also:
setNumTicks
 o setNumTicks
 public void setNumTicks(int v)
Sets the number of tick marks to be displayed (default: 0). If this value is non-zero, it overrides the AutoTick value.

See Also:
setAutoTick
 o getMinimumLabel
 public JCLabel getMinimumLabel()
Gets the MinimumLabel value. This will be null if no label has been set.

See Also:
setMinimumLabel
 o setMinimumLabel
 public void setMinimumLabel(JCLabel l)
Sets the label to be displayed at the slider's minimum end (the top or left, depending on the orientation).

 o getMinimumLabelString
 public String getMinimumLabelString()
Gets the MinimumLabel value. This will be null if no label has been set.

See Also:
setMinimumLabel
 o setMinimumLabelString
 public void setMinimumLabelString(String l)
Sets the label to be displayed at the slider's minimum end (the top or left, depending on the orientation).

 o getMaximumLabelString
 public String getMaximumLabelString()
Gets the MaximumLabel value. This will be null if no label has been set.

See Also:
setMaximumLabel
 o setMaximumLabelString
 public void setMaximumLabelString(String l)
Sets the label to be displayed at the slider's maximum end (the bottom or right, depending on the orientation).

 o getMaximumLabel
 public JCLabel getMaximumLabel()
Gets the MaximumLabel value. This will be null if no label has been set.

See Also:
setMaximumLabel
 o setMaximumLabel
 public void setMaximumLabel(JCLabel l)
Sets the label to be displayed at the slider's maximum end (The bottom or right, depending on the orientation).

 o preferredWidth
 protected int preferredWidth()
Gets the subclass' preferred width (default: 100).

Overrides:
preferredWidth in class JCContainer
 o preferredHeight
 protected int preferredHeight()
Gets the subclass' preferred height (default: 100).

Overrides:
preferredHeight in class JCContainer
 o resizeThumb
 protected void resizeThumb(int w,
                            int h)
Disallows resizing the slider.

 o layout
 public synchronized void layout()
Overrides:
layout in class Container
 o drawTicks
 protected void drawTicks(Graphics g,
                          int num_ticks)
Draws the tick marks.

 o paintInterior
 public void paintInterior(Graphics g)
Draws the trough and thumb.

Overrides:
paintInterior in class JCContainer

All Packages  Class Hierarchy  This Package  Previous  Next  Index