• An applet
is a program written in the Java programming language that can be included in
an HTML page, much in the same way an image is included in a page.
• When you
use a Java technology-enabled browser to view a page that contains an applet,
the applet's code is transferred to your system and executed by the browser's
Java Virtual Machine (JVM).
runs in the browser and its lifecycle method are called by JVM when it is
loaded and destroyed. Here are the lifecycle methods of an Applet:
This method is called to initialized an applet
This method is called after the initialization of the applet.
This method can be called multiple times in the life cycle of an Applet.
This method is called only once in the life cycle of the applet when applet is
init () method:
• The life
cycle of an applet is begin on that time when the applet is first loaded into
the browser and called the init() method.
init() method is called only one time in the life cycle on an applet. The
init() method is basically called to read the PARAM tag in the html file. The
init () method retrieve the passed parameter through the PARAM tag of html file
using get Parameter() method
• All the
initialization such as initialization of variables and the objects like image,
sound file are loaded in the init () method .After the initialization of the
init() method user can interact with the Applet and mostly applet contains the
Start () method:
• The start
method of an applet is called after the initialization method init().
method may be called multiples time when the Applet needs to be started or
restarted. For Example if the user wants to return to the Applet, in this
situation the start Method() of an Applet will be called by the web browser and
the user will be back on the applet.
• In the
start method user can interact within the applet.
Stop () method:
stop() method can be called multiple times in the life cycle of applet like the
start () method. Or should be called at least one time.
• There is
only miner difference between the start() method and stop () method. Example
the stop() method is called by the web browser on that time When the user
leaves one applet to go another applet and the start() method is called on that
time when the user wants to go back into the first program or Applet.
destroy() method is called only one time in the life cycle of Applet like
method is called only on that time when the browser needs to Shut down.