//
import java.awt.*;

public class Button extends Widget
{
   String[] labels = {"BUTTON"};
   private int value = 0;

//---------------- OBJECT CONSTRUCTOR

   public Button(int x, int y, int width, int height) {
      super(x, y, width, height);
   }

//---------------- GET A VALUE

   public void setValue(int n) { value = n; }
   public int getValue() { return value; }

//---------------- HANDLING MOUSE EVENTS

   public boolean up(int x, int y) {       // UP EVENT
      if (super.up(x,y)) {
         if (inside(x,y))
	    value = (value + 1) % labels.length;
         return true;
      }
      return false;
   }

//---------------- RENDERING THE WIDGET

   public void render(Graphics g) {
      g.setColor(bgColor);
      g.fill3DRect(x, y, width, height, ! isDown);

      g.setColor(fgColor);
      g.drawString(labels[value], x+2, y+12);
   }
}