Advanced Java Tutorial


Total available pages count: 55
Subject - Java Technologies

Life cycle in applet

Life cycle in Applet

Applet has 5 stage:

  • init() method
  • start() method
  • stop() method
  • destroy() method
  • paint() method

 

init()

The method is used to initialize when the applet is executed. declaration of variable & initialization operation performed in the init() method. The method invoked only once.

public void init()

 

Start()

The method includes the actual code of the applet that use to run, it executes immediately after the init() method. It also executes whenever the applet is restored & maximizes or moves from one to the next tab in the browser. the method uses to start the applet.
 

public void start()

 

Stop()

The method stops the execution of the applet.it executed when an applet is minimized or when moving from one to the next tab in the browser.
 

public void stop()

 

Destroy()

The method executed when the applet is closed or when the tab containing the webpage gets closed. The Stop() method executes just before when destroy() is getting invoked. This method removes all objects of the applet from the memory.

 

public void destroy()

 

Paint()

The method is used to redraw the output on the applet display. The paint () method is part of the applet but we are not considering it in the life cycle of an applet. It gets executed after the execution of start() & whenever the applet is resized.

public void paint(Graphics g)

 

In the method of execution sequence, when applet get executed init(),start() & paint() method get called &  when applet get closed stop() & destroy() method called.



Comments