/*
 * Created on Nov 27, 2004
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package testappletpack;

import java.applet.Applet;
import java.awt.Graphics;
import java.awt.TextField;

/**
 * @author brian
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class myapplet extends Applet {
	StringBuffer buffer;
	 TextField field;

	public void init() {
		buffer = new StringBuffer();
	        addItem("initializing... ");
//	      Create the text field and make it uneditable.
	        field = new TextField();
	        field.setEditable(false);

		//Set the layout manager so that the text field will be
		//as wide as possible.
	        setLayout(new java.awt.GridLayout(1,0));

		//Add the text field to the applet.
	        add(field);
	        validate();

	        addItem("initializing... ");

	    }
		void addItem(String newWord) {
        //This used to append the string to the StringBuffer;
        //now it appends it to the TextField.
        String t = field.getText();
        System.out.println(newWord);
        field.setText(t + newWord);
        repaint();
    }

	    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);
	        buffer.append(newWord);
	        repaint();
	    }*/
	    public void paint(Graphics g) {
	    	//Draw a Rectangle around the applet's display area.
	            g.drawRect(0, 0, size().width - 1, size().height - 1);

	    	//Draw the current string inside the rectangle.
	            g.drawString(buffer.toString(), 5, 15);
	        }


}
