In this post, we will see Life Cycle of an Applet.
Watch following video ( Java Applet Tutorial | Java Applet Life Cycle | Hello World Applet Program in Java ) :
Watch on YouTube: https://www.youtube.com/watch?v=3RyPFiR8qoE
Check following diagram:
Life Cycle of Applet consists of four phases:
1. Applet Initialized:
Objects regarding Applet get initialized in this phase. An init() method is called for the same purpose.
2. Applet Running:
Applets are embedded in a webpage. When a part of webpage which consists of applet is shown on a screen, then applet is in Running phase. A start() method is called, which takes applet to the Running phase.
3. Applet Stopped:
When a webpage in minimized or webpage is scrolled down/up; so that, applet is disappeared from the screen, then applet is in Stopped phase. Stop() method is called when applet is disappeared from the screen.
4. Applet Destroyed:
When you closed the webpage which consists of applet, applet is get destroyed. A destroy() method is called when applet is destroyed.
Note: public void init(), public void start(), public void stop(), public void destroy() methods are given by Applet class. Applet class is given by package java.applet.
One more method, public void paint(Graphics g) , is used in life cycle of applet. It is used to redraw applet. It is given by Component class. Component class is given by package java.awt.