import java.applet.*; import java.awt.*; import java.awt.event.*; public class PenTablet extends Applet implements ActionListener, KeyListener, ItemListener, TextListener { TextField textField; Choice choice; Label textFieldLabel, choiceLabel; public void init() { setBackground(new Color(225,225, 255)); textField = new TextField("Initial"); textField.addActionListener(this); textField.addKeyListener(this); textField.addTextListener(this); add(textField); textFieldLabel = new Label("Initial"); add(textFieldLabel); choice = new Choice(); choice.addItem("First "); choice.addItem("Second "); choice.addItem("Third "); choice.addItemListener(this); add(choice); choiceLabel = new Label("First "); add(choiceLabel); } void refreshTextFieldLabel() { textFieldLabel.setText(textField.getText()); textFieldLabel.invalidate(); invalidate(); validate(); } public void actionPerformed(ActionEvent ae) { System.out.println("Action"); if (ae.getSource() == textField) refreshTextFieldLabel(); } public void keyPressed(KeyEvent ke){} public void keyReleased(KeyEvent ke) { System.out.println("Key"); refreshTextFieldLabel(); } public void textValueChanged(TextEvent te) { System.out.println("Text"); refreshTextFieldLabel(); } public void keyTyped(KeyEvent ke){} public void itemStateChanged(ItemEvent ie) { System.out.println("Item"); if (ie.getSource() == choice) { choiceLabel.setText(choice.getItem(choice.getSelectedIndex())); choiceLabel.invalidate(); invalidate(); validate(); } } } // END OF Class PenTablet