Applet Life Cycle in Java

Applet is a special Java program that are primarily used in a internet programming. 

Applet program runs on a web browser at client side. Applet program are used to make the web site more dynamic.

When the applet program is loaded is passes through several stages:

Java Applet Life Cycle
Java Applet Life Cycle

Born:  Also known as initialization state.  It is the first state of applet lifecycle.

Applet enters in a born/initialization state when it is first loaded.  

Applet moves in a born state when init() method of Applet class executes.

Applet initialization occurs once in a  applet lifecycle. Inside the init() method we initialize all the variables.

Syntax of init() 

Running :  Applet enters in a running state from born state when a start() method of Applet class executes.  

Running sates call automatically when the initialization phase completes. 

Applet also comes in a running state from idle state when idle applet again get processor.

Running sates call automatically when the initialization phase completes. 

Applet also comes in a running state from idle state when idle applet again get processor.

Syntax of start()              

Idle : A running appletenters in a idle sate from running state when execution of start complete.

In a another words when we leave the page of running applet then automatically it enters in a idle sate from running state.

Applet moves in idle state when  stop() method executes and it moves idle to running state when again start() calls.

Syntax of stop()               

Dead :  An applet is moved to dead state when we quit the web browser.  When applet moves in a dead state it removed from memory. 

The Applet will be terminate when destroy () method calls. In a applet lifecycle, applet terminates/destroys ones.

Syntax of destroy()        

Display State: The Display state executes immediately after when applet enters in a running state.

In this state we display the information on the output screen using paint() method.