jcontrol.ui.vole
Class Slider

java.lang.Object
  |
  +--jcontrol.ui.vole.Component
        |
        +--jcontrol.ui.vole.Slider

public class Slider
extends Component

This is a graphical slider for JControl. The slider can be moved virtually left or right to simulate analog input.

Version:
1.1
Author:
Marcus Timmermann, Wolfgang Klingauf

Field Summary
 
Fields inherited from class jcontrol.ui.vole.Component
focusOwner, font, g, height, listener, parent, visible, width, x, y
 
Constructor Summary
Slider(int min, int max)
          Constructs a new slider with minimum and maximum value.
Slider(int min, int max, int step)
          Constructs a new slider with minimum and maximum value.
Slider(int min, int max, int step, int x, int y, int width)
          Constructs a slider and sets bounds.
 
Method Summary
 int getValue()
          Get slider value.
 boolean onKeyEvent(KeyEvent event)
          Handle KeyEvents.
 void paint()
          Repaint the Slider.
 void setActionListener(ActionListener listener)
          Add an ActionListener to the button.
 void setValue(int value)
          Set the slider value.
 
Methods inherited from class jcontrol.ui.vole.Component
getBounds, getParent, isVisible, onActionEvent, remove, removeFocus, requestFocus, setBounds, setFont, setGraphics, setLocation, setParent, setVisible, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, notifyAll, wait
 

Constructor Detail

Slider

public Slider(int min,
              int max)
Constructs a new slider with minimum and maximum value.

Parameters:
min - the slider's minimum value (>= 0)
max - the slider's maximum value.

Slider

public Slider(int min,
              int max,
              int step)
Constructs a new slider with minimum and maximum value.

Parameters:
min - the slider's minimum value (>= 0)
max - the slider's maximum value.
step - slider value is incremented by step when KEY_SELECT is avtivated

Slider

public Slider(int min,
              int max,
              int step,
              int x,
              int y,
              int width)
Constructs a slider and sets bounds.

Parameters:
x - the upper left x coordinate.
y - the upper left y coordinate.
min - the slider's minimum value (>= 0)
max - the slider's maximum value.
step - slider value is incremented by step when KEY_SELECT is activated
Method Detail

getValue

public int getValue()
Get slider value.

Returns:
int The current value.

onKeyEvent

public boolean onKeyEvent(KeyEvent event)
Handle KeyEvents.

Overrides:
onKeyEvent in class Component
Parameters:
event - the KeyEvent
Returns:
If this method returns true, the KeyEvent is handled by the super Container.
See Also:
Component.onKeyEvent(KeyEvent)

paint

public void paint()
Repaint the Slider.

Overrides:
paint in class Component

setActionListener

public void setActionListener(ActionListener listener)
Add an ActionListener to the button. It will receive ActionEvents when the slider is moved. The current value is represented as String and can be read using the ActionEvent.getActionCommand() method.

Parameters:
listener - The new ActionListener or null.

setValue

public void setValue(int value)
Set the slider value.

Parameters:
value - The new value.