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

Constructor Index

 o ValueBar()
Default constructor.
 o ValueBar(String, int, boolean)
The contructor you should use! The lines below describes the arguments: label What the bar represents.

Method Index

 o getValue()
 o main(String[])
Use the main method to test what this class can do and looks like.
 o mouseDown(Event, int, int)
If the ValueBar object is editable, then this method will update the internal value when the bar is clicked.
 o paint(Graphics)
Draw the bar that represents the value stored in this object.
 o setValue(int)
Set the value of this object.

Constructors

 o ValueBar
  public ValueBar()
Default constructor. Do not use this one.
 o 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.

Methods

 o paint
  public void paint(Graphics g)
Draw the bar that represents the value stored in this object.
Overrides:
paint in class Component
 o 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
 o getValue
  public int getValue()
Returns:
Return the value currently stored in this object.
 o 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.
 o main
  public static void main(String a[])
Use the main method to test what this class can do and looks like.