Class ValueBar
Class ValueBar
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----ValueBar
- public class ValueBar
- extends Panel
Holds and displays an integer value between 0-100;
- Version:
- 1.1
- Author:
- Torbjörn Nilsson
-
ValueBar()
-
Default constructor.
-
ValueBar(String, int, boolean)
-
The contructor you should use! The lines below describes the arguments:
label What the bar represents.
-
getValue()
-
-
main(String[])
- Use the main method to test what this class can do and looks like.
-
mouseDown(Event, int, int)
- If the ValueBar object is editable, then this method
will update the internal value when the bar is clicked.
-
paint(Graphics)
- Draw the bar that represents the value stored in this object.
-
setValue(int)
- Set the value of this object.
ValueBar
public ValueBar()
- Default constructor. Do not use this one.
ValueBar
public ValueBar(String label,
int value,
boolean edit)
- The contructor you should use! The lines below describes the arguments:
label What the bar represents.
value Initial value(0-100).
edit If it is possible to edit this value by clicking on the bar with the mouse.
paint
public void paint(Graphics g)
- Draw the bar that represents the value stored in this object.
- Overrides:
- paint in class Component
mouseDown
public boolean mouseDown(Event e,
int x,
int y)
- If the ValueBar object is editable, then this method
will update the internal value when the bar is clicked.
- Overrides:
- mouseDown in class Component
getValue
public int getValue()
- Returns:
- Return the value currently stored in this object.
setValue
public void setValue(int x)
- Set the value of this object. Checks that value is in range 0-100.
If out of range the value is not changed, but error message is printed.
main
public static void main(String a[])
- Use the main method to test what this class can do and looks like.