import java.awt.*; import java.applet.*; public class ChooseAColor extends Applet { TextField textField1; public void init() { textField1 = new TextField(5); add(textField1); } public void paint(Graphics g) { g.drawString("3. Green", 40, 115); String s = textField1.getText(); int choice = Integer.parseInt(s); if (choice == 1) g.setColor(Color.red); else if (choice == 2) g.setColor(Color.blue); else if (choice == 3) g.setColor(Color.green); else g.setColor(Color.black); if ((choice >= 1) && (choice <= 3)) g.drawString("This is the color you chose.", 60, 140); else g.drawString("Invalid menu selection.", 60, 140); } public boolean action(Event event, Object arg) { repaint(); return true; } }