Applet Life Cycle in Java

Reviews of webeduclick.comEvery Java applet inherits a set of default behaviours from the Applet class. As a result, when an applet is loaded, it undergoes a series of changes in its states. The methods to execute in the Applet Life Cycle are init(), start(), stop(), destroy().

The Applet Life Cycle is included in Fig:
applet life-cycle

  • Born or Initialization State
  • Running State
  • Idle State
  • Dead State

1. Born or Initialization State: Applets enters the initialization state when it is first loaded. It is achieved by init() method of Applet class. Then applet is born.

public void init()
{
.............
.............
(Action)
}

2. Running State: Applet enters the running state when the system calls the start() method of Applet class. This occurs automatically after the applet is initialized.

public void start()
{
.............
.............
(Action)
}

3. Idle State: An applet becomes idle when it is stopped from running. Stopping occurs automatically when we leave the page containing the currently running applet. This is achieved by calling the stop() method explicitly.

public void stop()
{
.............
.............
(Action)
}

4. Dead State: An applet is said to be dead when it is removed from memory. This occurs automatically by invoking the destroy() method when we want to quit the browser.

public void destroy()
{
.............
.............
(Action)
}

Recommended Posts:

Advanced Java
    1. Java Applet
    2. Applet Life Cycle in Java
    3. Difference Between Applet and Application
    4. Creating an Executable Applet in Java
    5. Displaying Numerical values in Applet
    6. An Applet Program to Add Two Numbers
    7. Event Handling in Applet
    8. AWT Event Classes
    9. AWT Graphics Class
    10. Draw a line and rectangle in Java Applet
    11. Draw Circles and Ellipses in Java Applet
    12. Draw a Polygon in Java Applet
    13. AWT Hierarchy | AWT Package
    14. Swing in Core Java