Wednesday 18 February 2015

Lifecycle methods for Applet

Lifecycle methods for Applet:

The java.applet.Applet class 4 life cycle methods and java.awt.Component class provides 1 life cycle methods for an applet.

java.applet.Applet class:

For creating any applet java.applet.Applet class must be inherited. It provides 4 life cycle methods of applet.
  1. public void init(): is used to initialized the Applet. It is invoked only once.
  2. public void start(): is invoked after the init() method or browser is maximized. It is used to start the Applet.
  3. public void stop(): is used to stop the Applet. It is invoked when Applet is stop or browser is minimized.
  4. public void destroy(): is used to destroy the Applet. It is invoked only once.

java.awt.Component class:

The Component class provides 1 life cycle method of applet.
  1. public void paint(Graphics g): is used to paint the Applet. It provides Graphics class object that can be used for drawing oval, rectangle, arc etc.

Who is responsible to manage the life cycle of an applet?

Java Plug-in software.

No comments:

Post a Comment