Home Java Example Java Applet The Life cycle of An Applet

Related Tutorials


 
 

Share on Google+Share on Google+

The Life cycle of An Applet

Advertisement
In this Section you will learn about the lifecycle of an applet and different methods of an applet.

The Life cycle of An Applet

     

Introduction

In this Section you will learn about the lifecycle of an applet and different methods of an applet. Applet 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: 

init(): This method is called to initialized an applet

start(): This method is called after the initialization of the applet.

stop(): This method can be called multiple times in the life cycle of an Applet.

destroy(): This method is called only once in the life cycle of the applet when applet is destroyed.

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. The 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 init() method.

Start () method: The start method of an applet is called after the initialization method init(). This 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:  The 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. For 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: The destroy() method is called  only one time in the life cycle of Applet like init() method. This method is called only on that time when the browser needs to Shut down.

 

http://staff.science.uva.nl/~heck/Courses/JAVAcourse/ch6/s1.html

 

http://www.hostitwise.com/java/japplet.html

 

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 14, 2007

Related Tutorials

Discuss: The Life cycle of An Applet   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:6
Samir Joglekar
June 5, 2011
Applet Life Cycle

I think there are three more methods - paint(), repaint() and update().
brahmamkv
June 8, 2011
java

tutorials are very nice.try to include more theory
sandeep
June 16, 2011
java programming

tgis article about java applet life cycle is too good .
P
February 13, 2012
JAVA

diffarent stage in the life cycle of an applet.
Tejaswi
March 29, 2012
Life cycle methods of an applet

init(): This method is called to initialized an applet start(): This method is called after the initialization of the applet. stop(): This method can be called multiple times in the life cycle of an Applet. destroy(): This method is called only once in the life cycle of the applet when applet is destroyed.
udhaya
October 22, 2012
java

super
DMCA.com