import java.awt.*;
import java.awt.event.*;

    // Example showing a listener to multiple buttons.
class MultiButtonFrame1 extends Frame implements ActionListener {
    // Labels (and action commands) for two buttons.
    static final String BOTTOM = "Bottom", TOP = "Top";

    public MultiButtonFrame1(){
        final int width = 200, height = 200;
        setSize(width,height);

        // Place a dummy button at the top of the frame.
        Button top = new Button(TOP);
        top.setActionCommand(TOP);
        // We wish to know about button presses.
        top.addActionListener(this);
        add(top,"North");

        Button bottom = new Button(BOTTOM);
        bottom.setActionCommand(BOTTOM);
        // We wish to know about button presses.
        bottom.addActionListener(this);
        add(bottom,"South");
    }

        // Implment the ActionListener interface.
        // Receive events from the buttons.
    public void actionPerformed(ActionEvent e){
        final String command = e.getActionCommand();
        if(command.equals(TOP)){
            System.out.println(TOP+" received.");
        }
        else if(command.equals(BOTTOM)){
            System.out.println(BOTTOM+" received.");
        }
        else{
            System.out.println("Unexpected command "+command+
                               " received.");
        }
    }
}
