/** A very simple expamle of a Java GUI applet **/ // AWT components and Event classes used: import java.applet.Applet; import java.awt.Button; import java.awt.Frame; import java.awt.event.ActionListener; // interface import java.awt.event.ActionEvent; // events that interface relates to public class SimpleApplet extends Applet implements ActionListener { // we don't need a frame; the applet itself is a kind of // (extends a) GUI component container called a Panel. private Button doSomethingButton = null; /** Constructor: make a frame to hold the GUI components and the ** GUI components themselves. **/ public void init() { doSomethingButton = new Button("Do Something"); // This object that is being constructed agrees to listen for // events the button will generate. doSomethingButton.addActionListener(this); // add the button to the applet add(doSomethingButton); } /** run the application **/ public void start() { // the browser will make the components visible } public void stop() { } public void destroy() { } public void actionPerformed(ActionEvent e) { // Where do you think thhis output will appear? System.out.println("You pressed the button"); } }