/*  
 *  ===========================================================================
 *  AppletAnatomy.java : This program exercises the basic applet methods ...
 *  init()...start()...stop()...destroy().
 *
 *  Written By : Mark Austin                                        March, 2001
 *  ===========================================================================
 */  

import javax.swing.*;
import javax.swing.event.*;
import javax.swing.SwingUtilities;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class AppletAnatomy extends JApplet {

    StringBuffer buffer;

    // init() initializes the applet each time it is loaded....

    public void init() {
       buffer = new StringBuffer();
       addStringItem("...in init()");
    }

    // start() starts the applet execution, such as when the applet is loaded
    //         or when the user revisits a page that contains the applet

    public void start() {
       addStringItem("...in start()");

       // display buffer contents on Jlabal ....

       getContentPane().add(
          new JLabel( buffer.toString() , JLabel.CENTER)
       );
    }

    // stop() stop the applet execution, for example, when a user leaves
    //        the applet's page or quits the browser.

    public void stop() {
       addStringItem("...in stop()");
    }

    // destroy() performs a final cleanup in preparation for unloading.

    public void destroy() {
       addStringItem("...in destroy()");
    }

    // ==============================
    // Append string to strung buffer
    // ==============================

    void addStringItem ( String newWord ) {
       System.out.println(newWord);
       buffer.append( newWord );
    }
}
