Turn Desktop View Off
by Dinesh Thakur Category: AWT and Applets

Java applet inherits features from the class Applet. Thus, whenever an applet is created, it undergoes a series of changes from initialization to destruction. Various stages of an applet life cycle are depicted in the figure below:

 

                     Applet Life cycle

Initial State

When a new applet is born or created, it is activated by calling init() method. At this stage, new objects to the applet are created, initial values are set, images are loaded and the colors of the images are set. An applet is initialized only once in its lifetime. It's general form is:

 

public void init( )

//Action to be performed

}

 

Running State

 

An applet achieves the running state when the system calls the start() method. This occurs as soon as the applet is initialized. An applet may also start when it is in idle state. At that time, the start() method is overridden. It's general form is:

 

public void start( )

{

//Action to be performed

}

 

Idle State

 

An applet comes in idle state when its execution has been stopped either implicitly or explicitly. An applet is implicitly stopped when we leave the page containing the currently running applet. An applet is explicitly stopped when we call stop() method to stop its execution. It's general form is:

 

public void stope

{

//Action to be performed

}

Dead State

 

An applet is in dead state when it has been removed from the memory. This can be done by using destroy() method. It's general form is:

 

public void destroy( )

{

//Action to be performed

}

 

Apart from the above stages, Java applet also possess paint( ) method. This method helps in drawing, writing and creating colored backgrounds of the applet. It takes an argument of the graphics class. To use The graphics, it imports the package java.awt.Graphics





About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles