import java.applet.*; import java.awt.*; public class choices extends Applet { String currentColor; Choice theoptions = new Choice(); public void init() { add(new Label("The choice box allows easy selection")); add(new Label("of items and conserves space.")); add(new Label("You can make the choices blend with labels")); add(new Label("and produce smooth flowing interaction.")); add(new Label("Like the one below this label.")); add(new Label("I want the screen color to be")); theoptions.addItem("Red"); theoptions.addItem("Green"); theoptions.addItem("Blue"); theoptions.addItem("White"); theoptions.addItem("Cyan"); theoptions.addItem("Yellow"); add(theoptions); } public boolean action(Event evt, Object whichAction) { if (!(evt.target instanceof Choice)) { return false; } Choice whichChoice = (Choice) evt.target; if (whichChoice == theoptions) { currentColor = (String) whichAction; repaint(); return true; } return false; } public void paint(Graphics g) { if (currentColor=="Red") setBackground(Color.red); if (currentColor=="White") setBackground(Color.white); if (currentColor=="Blue") setBackground(Color.blue); if (currentColor=="Green") setBackground(Color.green); if (currentColor=="Cyan") setBackground(Color.cyan); if (currentColor=="Yellow") setBackground(Color.yellow); } }