You are on page 1of 2

What is an Applet Skeleton?

How do you test( Compile and


run) your applet in java

ANS) The Applet skeleton is formed of four method


namely
The init () method- It is called the first time an applet is
loaded into the memory of computer. We can initialize
variables to the applet in the init() method.
The start () method-This method is called immediately
after init() and this is used for restarting a process .
The stop () method-It is called when applet loses focus .It
is used to reset variables and stop threads.
The destroy () method-It is called by the browser when
the user moves to another page. This helps in closing the
file like operations . destroy() method is called when your
applet needs to be removed completely from memory.

Thus ,init () initializes the applet . start() makes the applet


run. stop() stops the applet and applet gets destroyed by
destroy()

There are two ways to run an applet

1. By html file.
2. By appletViewer tool (for testing purpose).

For running the applet ,first in cmd we write


1)javac filename.java
2)appletviewer classname
CODE:
import java.applet.*;
public class AppletTest extends Applet
{
public void init()
{
//initialization
}
public void start ()
{
//start or resume execution
}
public void stop()
{
//suspend execution
{
public void destroy()
{
//perform shutdown activity
}
public void paint (Graphics g)
{
//display the content of window
}
}
TO COMPILE : javac AppletTest.java
TO RUN: appletviewer AppletTest

You might also like