import java.awt.*; import java.awt.event.*; import java.applet.*; public class ChoiceApplet03 extends Applet { Choice theChoice = new Choice(); TextField theTextField = new TextField(20); public void init() { theChoice.add("big"); theChoice.add("small"); theChoice.add("unknown"); add(theChoice); theChoice.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { System.out.println("ENTER----->theChoice ActionListener"); String mName = (String) e.getItem(); System.out.println("mName: " + mName); String pString = e.paramString(); // useful for Debugging System.out.println("pString: " + pString); theTextField.setText(mName); System.out.println("EXIT------>theChoice ActionListener"); } }); add(theTextField); theTextField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("ENTER----->theTextField ActionListener"); String mName = e.getActionCommand(); System.out.println("mName: " + mName); System.out.println("EXIT------>theTextField ActionListener"); } }); } public static void main(String args[]) { Applet theApplet = new ChoiceApplet03(); appletFrame theFrame = new appletFrame(); theFrame.add("Center", theApplet); theApplet.init(); theFrame.setSize(500,300); theFrame.setVisible(true); theApplet.start(); } } class appletFrame extends Frame implements WindowListener { appletFrame() { addWindowListener(this); } public void windowClosed(WindowEvent event) { } public void windowDeiconified(WindowEvent event) { } public void windowIconified(WindowEvent event) { } public void windowActivated(WindowEvent event) { } public void windowDeactivated(WindowEvent event) { } public void windowOpened(WindowEvent event) { } public void windowClosing(WindowEvent event) { System.out.println("ENTER-----appletFrame.windowClosing"); this.setVisible(false); dispose(); System.out.println("EXIT-----appletFrame.windowClosing"); System.exit(0); } }