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
Events
-
adjustmentListeners
- List of JCAdjustmentEvent listeners.
-
HORIZONTAL
-
-
thumb
- Scrollbar's thumb.
-
VERTICAL
-
-
JCSlider()
- Creates a horizontal slider.
-
JCSlider(int)
- Constructs a slider with the specified orientation.
-
JCSlider(int, Applet, String)
- Creates a slider which reads parameters from the applet's HTML file.
-
JCSlider(int, int, int, int)
- Constructs a slider with an initial orientation,
value, and minimum and maximum values.
-
addAdjustmentListener(JCAdjustmentListener)
- Adds the specified adjustment listener to receive adjustment events.
-
check(int)
-
-
dragging()
-
-
drawTicks(Graphics, int)
- Draws the tick marks.
-
getAutoTick()
- Gets the AutoTick value.
-
getBlockIncrement()
- Gets the page increment.
-
getMaximum()
- Gets the maximum value.
-
getMaximumLabel()
- Gets the MaximumLabel value.
-
getMaximumLabelString()
- Gets the MaximumLabel value.
-
getMinimum()
- Gets the minimum value.
-
getMinimumLabel()
- Gets the MinimumLabel value.
-
getMinimumLabelString()
- Gets the MinimumLabel value.
-
getNumTicks()
- Returns the NumTicks value.
-
getOrientation()
- Gets the orientation.
-
getParameters()
- Reads the parameter values from the HTML page using the component's applet.
-
getThumbSize()
- Gets the thumb's size.
-
getUnitIncrement()
- Gets the line increment.
-
getValue()
- Gets the current value.
-
getVisibleAmount()
- Returns the thumb size, in user units
-
keyDown(Event, int)
- Moves the slider if HOME, END, PGUP, PGDN or an arrow key is hit.
-
layout()
-
-
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.
-
moveThumb()
- Moves the slider.
-
paintInterior(Graphics)
- Draws the trough and thumb.
-
paintThumb(Graphics)
- Paints the thumb.
-
preferredHeight()
- Gets the subclass' preferred height (default: 100).
-
preferredWidth()
- Gets the subclass' preferred width (default: 100).
-
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.
-
resizeThumb(int, int)
- Disallows resizing the slider.
-
setAutoTick(boolean)
- If true (default), a tick mark is drawn at each page increment.
-
setBackground(Color)
-
Sets the background color.
-
setBlockIncrement(int)
- Sets the page increment.
-
setLayout(LayoutManager)
-
Sets the layout manager for this container.
-
setMaximum(int)
- Sets the maximum value (default: 100).
-
setMaximumLabel(JCLabel)
- Sets the label to be displayed at the slider's maximum end
(The bottom or right, depending on the orientation).
-
setMaximumLabelString(String)
- Sets the label to be displayed at the slider's maximum end
(the bottom or right, depending on the orientation).
-
setMinimum(int)
- Sets the minimum value.
-
setMinimumLabel(JCLabel)
- Sets the label to be displayed at the slider's minimum end
(the top or left, depending on the orientation).
-
setMinimumLabelString(String)
- Sets the label to be displayed at the slider's minimum end
(the top or left, depending on the orientation).
-
setNumTicks(int)
- Sets the number of tick marks to be displayed (default: 0).
-
setOrientation(int)
- Sets the orientation.
-
setThumbSize(Dimension)
- Sets the thumb's size (default: 21x11 for a vertical slider,
11x21 for a horizontal slider).
-
setUnitIncrement(int)
- Sets the line increment (default: BlockIncrement value).
-
setValue(int)
- Sets the value.
-
setValue(int, boolean)
- Sets the value.
-
setValues(int, int, int)
- Sets the values.
-
setVisibleAmount(int)
- Sets the thumb size, in user units.
-
toPixels(int)
- Converts from scrollbar scale to screen pixels.
-
toValue(int)
- Converts from screen pixels to scrollbar scale.
HORIZONTAL
public static final int HORIZONTAL
VERTICAL
public static final int VERTICAL
thumb
protected ScrollbarThumb thumb
- Scrollbar's thumb.
adjustmentListeners
protected JCVector adjustmentListeners
- List of JCAdjustmentEvent listeners.
JCSlider
public JCSlider()
- Creates a horizontal slider. No parameters are read from an HTML file
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.
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
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
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
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
getOrientation
public int getOrientation()
- Gets the orientation.
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
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
check
protected int check(int value)
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
setMaximum
public synchronized void setMaximum(int v)
- Sets the maximum value (default: 100).
- See Also:
- setValues
getBlockIncrement
public int getBlockIncrement()
- Gets the page increment.
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.
dragging
public boolean dragging()
- Returns:
- true if the user is currently dragging the scrollbar's thumb
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
moveThumb
protected void moveThumb()
- Moves the slider.
paintThumb
protected void paintThumb(Graphics gc)
- Paints the thumb.
toPixels
protected int toPixels(int value)
- Converts from scrollbar scale to screen pixels.
toValue
protected int toValue(int value)
- Converts from screen pixels to scrollbar scale.
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
getMaximum
public int getMaximum()
- Gets the maximum value.
getThumbSize
public Dimension getThumbSize()
- Gets the thumb's size.
- See Also:
- setThumbSize
setThumbSize
public void setThumbSize(Dimension d)
- Sets the thumb's size (default: 21x11 for a vertical slider,
11x21 for a horizontal slider).
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
getUnitIncrement
public int getUnitIncrement()
- Gets the line increment.
getVisibleAmount
public int getVisibleAmount()
- Returns the thumb size, in user units
- See Also:
- setVisibleAmount
setVisibleAmount
public synchronized void setVisibleAmount(int v)
- Sets the thumb size, in user units.
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).
getAutoTick
public boolean getAutoTick()
- Gets the AutoTick value.
- See Also:
- setAutoTick
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
getNumTicks
public int getNumTicks()
- Returns the NumTicks value.
- See Also:
- setNumTicks
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
getMinimumLabel
public JCLabel getMinimumLabel()
- Gets the MinimumLabel value. This will be null if no label has been set.
- See Also:
- setMinimumLabel
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).
getMinimumLabelString
public String getMinimumLabelString()
- Gets the MinimumLabel value. This will be null if no label has been set.
- See Also:
- setMinimumLabel
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).
getMaximumLabelString
public String getMaximumLabelString()
- Gets the MaximumLabel value. This will be null if no label has been set.
- See Also:
- setMaximumLabel
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).
getMaximumLabel
public JCLabel getMaximumLabel()
- Gets the MaximumLabel value. This will be null if no label has been set.
- See Also:
- setMaximumLabel
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).
preferredWidth
protected int preferredWidth()
- Gets the subclass' preferred width (default: 100).
- Overrides:
- preferredWidth in class JCContainer
preferredHeight
protected int preferredHeight()
- Gets the subclass' preferred height (default: 100).
- Overrides:
- preferredHeight in class JCContainer
resizeThumb
protected void resizeThumb(int w,
int h)
- Disallows resizing the slider.
layout
public synchronized void layout()
- Overrides:
- layout in class Container
drawTicks
protected void drawTicks(Graphics g,
int num_ticks)
- Draws the tick marks.
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