//
// This is sample for Java GUI Event Delegation Model(3).
// Added 2 components to be action listener for diferent event.
//
import java.applet.Applet;
import java.awt.event.*;
import java.awt.*;

public class ButtonChoiceExample extends Applet implements ActionListener,
ItemListener { // ActionListener interface for actionPerformed declare needed.
	       // ItemListener interface for itemStateChanged declare needed.
	       // Why use interface instead of class, to force you implement
	       // it by yourself.
	Button pusher = new Button("Please push me");
	Choice stooges = new Choice(); //stooges, 3 funny TV guys Choice is a
                                       // container,

	public void init() {
		setLayout(new FlowLayout());
		stooges.addItem("Larry"); //Added item component into choice container
		stooges.addItem("Curly");
		stooges.addItem("Moe");
		add(pusher);
		add(stooges); // Added choice container into Applet container
		pusher.addActionListener(this);// Added target into source listing
		stooges.addItemListener(this);
	}

	public void actionPerformed(ActionEvent e){
		System.out.println("Hit the button, state="+stooges.getSelectedItem());
	}

	public void itemStateChanged(ItemEvent evt) {
		System.out.println("choose stooage, item="+ evt.getItem());
	}
}
