import java.awt.*;
import java.awt.event.*;

public class ButtonTest extends CloseableFrame implements ActionListener
  { public ButtonTest()
      { // build the user interface
        setLayout(new BorderLayout());
        Panel p = new Panel();
        Button yellowButton = new Button("Yellow");
        p.add(yellowButton);
        yellowButton.addActionListener(this);

        Button blueButton = new Button("Blue");
        p.add(blueButton);
        blueButton.addActionListener(this);

        add(p,"South");

        ta = new TextArea(3,20);
        add(ta,"North");
      }
    public void actionPerformed(ActionEvent evt)
      { String arg = evt.getActionCommand();
        Color  color = Color.black;
        if (arg.equals("Yellow")) color = Color.yellow;
        else if (arg.equals("Blue")) color = Color.blue;
        setBackground(color);
        repaint();
      }
    public static void main(String[] args)
      { Frame f = new ButtonTest();
        f.setVisible(true);
      }

  private TextArea ta;
  }



