SDSU CS 596 Java Programming
Fall Semester, 1998
Basic Applet Methods
To Applet Index
San Diego State University -- This page last updated 16-Dec-98

Description

This applet shows when the four basic methods (init(), start(), stop(), destroy() ) are called. You will not see the effects of the destroy method. To see start and stop go to a different page and return to this one. Try scrolling the window so the applet is out of view, then scroll back.

Applet

Your browser does not support Java applets, so you can not see this applet operate.

Applet Tag

<APPLET 
   archive="AppletClasses.jar" 
   code="BasicMethodsApplet.class" 
   width=300 height=200>
   Your browser does not support Java applets, so
   you can not see this applet operate.
</APPLET><BR>

Applet Source Code

BasicMethodsApplet.java

import java.awt.*;
import java.applet.Applet;

public class BasicMethodsApplet extends Applet
  {
  TextArea messages = new TextArea(8, 30);
  
  public BasicMethodsApplet() 
    {
    messages.append( "Constructor called\n" );
    }
      
  public void init() 
    {
    add( messages );
    messages.append( "Init called\n" );
    }
  
  public void start()
    {
    messages.append( "Start called\n" );
    }

  public void stop() 
    {
    messages.append( "Stop called\n" );
    }

  public void destroy() 
    {
    messages.append( "Destroy called\n" );
    }
  
  public void paint( Graphics display ) 
    {
    messages.append( "Paint called\n" );

    // Draw border
    Dimension size = getSize();
    display.drawRect( 0, 0, size.width-1, size.height-1);
    }
  }


Visitors since 16-Dec-98