/*
 * Simple3.java
 * Example is based on an example from
 * http://java.sun.com/docs/books/tutorial/index.html
 * Demonstrates Life Cycle of an Applet + Mouse Events + Scrolling
 */

// package pic20a;

import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.applet.Applet;
import java.awt.TextField;

public class Simple3 extends Applet implements MouseListener {

    TextField tField;

    public void init() {
	tField = new TextField();
	tField.setEditable(false);
	tField.addMouseListener(this);

	//set layout manager to get the widest textfield
	setLayout(new java.awt.GridLayout(1, 0));

	add(tField);
        addItem("initializing... ");
    }

    public void start() {
        addItem("starting... ");
    }

    public void stop() {
        addItem("stopping... ");
    }

    public void destroy() {
        addItem("preparing for unloading...");
    }

    void addItem(String newWord) {
        System.out.println(newWord);
	String t = tField.getText();
	tField.setText(t + newWord);
    }

    /*
     * The paint method is no longer necessary, since
     * the TextField repaints itself automatically.
     */

    /*
     * Implementation of MouseListener interface.
     * The following empty methods can be removed
     * by implementing a MouseAdapter (usually done
     * using an inner class).
     */
    public void mouseEntered(MouseEvent event) {
    }
    public void mouseExited(MouseEvent event) {
    }
    public void mousePressed(MouseEvent event) {
    }
    public void mouseReleased(MouseEvent event) {
    }

    public void mouseClicked(MouseEvent event) {
	addItem("click!... ");
    }
}
