
import java.awt.*;
import java.applet.*;

public class ButtonBox extends DrawBox {
	Choice choice;
  	Color color;

	public void init() {
              choice = new Choice ();

              choice.addItem ("Default");
              choice.addItem ("Red");
              choice.addItem ("Yellow");
              choice.addItem ("Blue");

	      color = getForeground();
              add (choice);
	}

        // if in drag mode, paint the current rectangle
        public void paint(Graphics g) {
                int beginX, beginY, width, height;
                if (dragMode == true) {
                        beginX = Math.min(startX, currentX);
                        beginY = Math.min(startY, currentY);
                        width = Math.abs(currentX - startX);
                        height = Math.abs(currentY - startY);

			g.setColor(color);
                        g.drawRect(beginX, beginY, width, height);
                }
        }


	public boolean action(Event event, Object arg) {

		if (event.target == choice) {
			String str = (String)arg;
			if (str.equals("Default")) 
				color = getForeground();
			else if (str.equals("Red")) 
				color = Color.red;
			else if (str.equals("Yellow"))
				color = Color.yellow;
			else color = Color.blue;

		}
		return true;
	}
}


	
