import java.awt.*; import java.applet.*; public class ChoiceApplet01 extends Applet { Choice theChoice = new Choice(); public void init() { theChoice.addItem("Choice item # 1"); theChoice.addItem("Choice item # 2"); theChoice.addItem("Choice item # 3"); add(theChoice); } public boolean action(Event event, Object arg) { System.out.println("ENTER----->action"); if (event.target == theChoice) System.out.println(theChoice.getSelectedItem() + " selected"); System.out.println("EXIT------>action"); return true; } public boolean handleEvent(Event e) { System.out.println(e.toString()); return super.handleEvent(e); } public static void main(String args[]) { Applet theApplet = new ChoiceApplet01(); appletFrame theFrame = new appletFrame(); theFrame.add("Center", theApplet); theApplet.init(); theFrame.resize(500,300); theFrame.show(); theApplet.start(); } } class appletFrame extends Frame { public boolean handleEvent(Event e) { if (e.id == Event.WINDOW_DESTROY) { this.hide(); this.dispose(); System.exit(0); return true; } else return super.handleEvent(e); } }