All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class dpscomponents.slider.MightySlider

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----dpscomponents.slider.MightySlider

public class MightySlider
extends Canvas
implements MouseListener, MouseMotionListener
A Slider is a widget that varies between a minimum and a maximum value. The user can drag a "thumb" to change the current value. As the slider is dragged, Motion() is called. When the slider is released, Release() is called. Override these two methods to give the slider behavior.

Version:
$Revision: 1.1.1.1 $, $Date: 1999/11/15 20:37:48 $.
Authors:
Adam Doppelt,
with some significant modifications by
Benjamin "Quincy" Cabell V,
Besiex Software.
Daren Stotler.

Variable Index

 o BUFFER
 o DEFAULT_DOUBLE_MAX
 o DEFAULT_DOUBLE_MIN
 o DEFAULT_HEIGHT
 o DEFAULT_WIDTH
 o MIN_HEIGHT
 o MIN_WIDTH
 o TEXT_BUFFER
 o textHeight_
 o THUMB_SIZE

Constructor Index

 o MightySlider()
Constructs a slider.

Method Index

 o getMinimumSize()
The minimum size of this slider is determined by any resizes the user has called on this component between the time it was instantiated and the time at which it is added to the layout manager (which calls this getMinimumSize() method), or if the user has not resized this component, the default height and width are used.
 o getPreferredSize()
The preferred size for this slider component is the same as its minimum size.
 o GetValue()
Returns the current value for the slider.
 o Motion()
This method is called when the "thumb" of the slider is dragged by the user.
 o mouseClicked(MouseEvent)
 o mouseDragged(MouseEvent)
And the MouseMotionListener methods.
 o mouseEntered(MouseEvent)
 o mouseExited(MouseEvent)
 o mouseMoved(MouseEvent)
 o mousePressed(MouseEvent)
Here are the MouseListener methods.
 o mouseReleased(MouseEvent)
An internal method used to handle mouse up events.
 o paint(Graphics)
An internal method used to handle repaint events.
 o Release()
This method is called when the "thumb" of the slider is released after being dragged.
 o SetBackgroundColor(Color)
Sets the background color for the slider.
 o SetBarColor(Color)
Sets the color for the slider's bar.
 o setBounds(int, int, int, int)
An internal method used to handle resizing.
 o SetDoubleMode(boolean)
 o SetFont(Font)
Sets the font for the slider`s text.
 o SetHeight(int)
Sets the height of the slider.
 o SetMaximum(double)
Sets the maximum value for the slider.
 o SetMaximum(int)
Sets the maximum value for the slider.
 o SetMinimum(double)
Sets the minimum value for the slider.
 o SetMinimum(int)
Sets the minimum value for the slider.
 o SetSlashColor(Color)
Sets the slash color for the slider.
 o SetTextColor(Color)
Sets the color for the slider`s text.
 o SetThumbColor(Color)
Sets the color for the slider's thumb.
 o SetValue(double)
Sets the current value for the slider.
 o SetValue(int)
Sets the current value for the slider.
 o SetWidth(int)
Sets the width of the slider.

Variables

 o THUMB_SIZE
 protected static final int THUMB_SIZE
 o BUFFER
 protected static final int BUFFER
 o textHeight_
 protected int textHeight_
 o TEXT_BUFFER
 protected static final int TEXT_BUFFER
 o DEFAULT_WIDTH
 protected static final int DEFAULT_WIDTH
 o DEFAULT_HEIGHT
 protected static final int DEFAULT_HEIGHT
 o MIN_WIDTH
 protected static final int MIN_WIDTH
 o MIN_HEIGHT
 protected static final int MIN_HEIGHT
 o DEFAULT_DOUBLE_MIN
 protected static final double DEFAULT_DOUBLE_MIN
 o DEFAULT_DOUBLE_MAX
 protected static final double DEFAULT_DOUBLE_MAX

Constructors

 o MightySlider
 public MightySlider()
Constructs a slider.

Methods

 o SetDoubleMode
 public void SetDoubleMode(boolean theMode)
 o getPreferredSize
 public Dimension getPreferredSize()
The preferred size for this slider component is the same as its minimum size.

Overrides:
getPreferredSize in class Component
 o getMinimumSize
 public Dimension getMinimumSize()
The minimum size of this slider is determined by any resizes the user has called on this component between the time it was instantiated and the time at which it is added to the layout manager (which calls this getMinimumSize() method), or if the user has not resized this component, the default height and width are used. The programmer should be careful to ensure that they do not resize this component to a size smaller than is needed to fit the display value (since no checking is done here to prevent that case).

Overrides:
getMinimumSize in class Component
 o Motion
 public void Motion()
This method is called when the "thumb" of the slider is dragged by the user. Must be overridden to give the slider some behavior.

 o Release
 public void Release()
This method is called when the "thumb" of the slider is released after being dragged. Must be overridden to give the slider some behavior.

 o SetMaximum
 public void SetMaximum(double num)
Sets the maximum value for the slider.

Parameters:
num - The new maximum (passed as a double).
 o SetMaximum
 public void SetMaximum(int num)
Sets the maximum value for the slider.

Parameters:
num - The new maximum (passed as an integer).
 o SetMinimum
 public void SetMinimum(double num)
Sets the minimum value for the slider.

Parameters:
num - The new minimum (passed as a double).
 o SetMinimum
 public void SetMinimum(int num)
Sets the minimum value for the slider.

Parameters:
num - The new minimum (passed as an integer).
 o SetValue
 public void SetValue(double num)
Sets the current value for the slider. The thumb will move to reflect the new setting.

Parameters:
num - The new setting for the slider (passed as a double).
 o SetValue
 public void SetValue(int num)
Sets the current value for the slider. The thumb will move to reflect the new setting.

Parameters:
num - The new setting for the slider (passed as an integer).
 o SetHeight
 public void SetHeight(int num)
Sets the height of the slider. This is the height of the entire slider canvas, including space reserved for displaying the current value.

Parameters:
num - The new height.
 o SetWidth
 public void SetWidth(int num)
Sets the width of the slider. This is the width of the actual slider box.

Parameters:
num - The new width.
 o GetValue
 public double GetValue()
Returns the current value for the slider.

Returns:
The current value for the slider.
 o SetBackgroundColor
 public void SetBackgroundColor(Color color)
Sets the background color for the slider. The "background" is the area outside of the bar.

Parameters:
color - The new background color.
 o SetThumbColor
 public void SetThumbColor(Color color)
Sets the color for the slider's thumb. The "thumb" is the box that the user can slide back and forth.

Parameters:
color - The new thumb color.
 o SetBarColor
 public void SetBarColor(Color color)
Sets the color for the slider's bar. The "bar" is the rectangle that the thumb slides around in.

Parameters:
color - The new bar color.
 o SetSlashColor
 public void SetSlashColor(Color color)
Sets the slash color for the slider. The "slash" is the little vertical line on the thumb.

Parameters:
color - The new slash color.
 o SetTextColor
 public void SetTextColor(Color color)
Sets the color for the slider`s text.

Parameters:
color - The new text color.
 o SetFont
 public void SetFont(Font font)
Sets the font for the slider`s text.

Parameters:
font - The new font.
 o paint
 public void paint(Graphics g)
An internal method used to handle repaint events.

Overrides:
paint in class Canvas
 o mousePressed
 public void mousePressed(MouseEvent evt)
Here are the MouseListener methods. Only two are nontrivial. An internal method used to handle mouse down events.

 o mouseReleased
 public void mouseReleased(MouseEvent evt)
An internal method used to handle mouse up events.

 o mouseClicked
 public void mouseClicked(MouseEvent evt)
 o mouseEntered
 public void mouseEntered(MouseEvent evt)
 o mouseExited
 public void mouseExited(MouseEvent evt)
 o mouseDragged
 public void mouseDragged(MouseEvent evt)
And the MouseMotionListener methods. Only need the drag one. An internal method used to handle mouse drag events.

 o mouseMoved
 public void mouseMoved(MouseEvent evt)
 o setBounds
 public void setBounds(int x,
                       int y,
                       int width,
                       int height)
An internal method used to handle resizing.

Overrides:
setBounds in class Component

All Packages  Class Hierarchy  This Package  Previous  Next  Index