java.lang.Object | +--com.sun.kjava.Slider
Slider: A graphical valuator object. Allows user to select a value by sliding a marker on a scale. This class isn't very graceful about handling conditions where the width of the slider is less than the interval of the maximum and minimum values. It calculates a "skip" value in these cases to increment the value for each pixel on the screen, e.g. Slider s1 = new Slider(5, 100, 100, 0, 1000, 0) creates a slider 100 pixels wide to handle the interval 0->1000. It then treats each pixel as being 10 units, and the user can only generate values in multiples of 10.
Constructor Summary | |
Slider()
Create a new Slider object. |
|
Slider(int x,
int y,
int w,
int mn,
int mx,
int initVal)
Create a Slider object. |
Method Summary | |
boolean |
contains(int x,
int y)
Is this point within the Slider's bounds? |
void |
drawMarker(int drawStyle)
Draw the Slider's marker. |
void |
handlePenDown(int x,
int y)
Deal with the fact that the pen went down. |
void |
handlePenMove(int x,
int y)
Deal with the fact that the pen moved. |
void |
paint()
Draw the Slider. |
void |
setLocation(int x,
int y)
Set the position of the Slider. |
void |
setSizeRange(int w,
int mn,
int mx,
int val)
Reset the width, limits, and value of the Slider. |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public Slider(int x, int y, int w, int mn, int mx, int initVal)
x
- the X coordinate of the Slider's positiony
- the Y coordinate of the Slider's positionw
- the widthmn
- the minimum valuemx
- the maximum valueinitVal
- the initial valuepublic Slider()
Method Detail |
public void setLocation(int x, int y)
x
- the new X coordinatey
- the new Y coordinatepublic void setSizeRange(int w, int mn, int mx, int val)
w
- the new widthmn
- the new minimum valuemx
- the new maximum valueval
- the new current valuepublic void paint()
public void drawMarker(int drawStyle)
drawStyle
- the style in which to draw it.public void handlePenMove(int x, int y)
x
- the X coordinate of the pen's new positiony
- the Y coordinate of the pen's new positionpublic void handlePenDown(int x, int y)
x
- the X coordinate of the pen's new positiony
- the Y coordinate of the pen's new positionpublic boolean contains(int x, int y)
x
- the X coordinate to testy
- the Y coordinate to test