import java.applet.Applet; import java.awt.*; import java.awt.event.*; /** * The ClickMe class implements an applet that simply puts up a button * thats ays click me and, when clicked, just prints out the canonical * "Hello World!" message. -- This is the AWT version * * @author Author * @version Version as of 2006-05-05 * For: CIS 355 with Professor Sethi * * Specification: * input(keyboard): * output(screen): ******************************************************************/ public class ClickMe extends Applet implements ActionListener { private TextField text1; private Button button1; public void init() { text1 = new TextField(20); button1 = new Button("Click me, please!"); add(text1); add(button1); button1.addActionListener(this); } public void actionPerformed(ActionEvent e) { String msg = new String ("Hello, World!"); if (e.getSource() == button1) { text1.setText(msg); } } }