What is APPLET ?

JAVA – APPLET

  • Applet is a type of java program .
  • Applet is embedded in the web pages and create/design  the dynamic web page / content.
  • Applet program runs inside web browser and works client sides.
  • Applet are use to create the dynamic and entertaining web site.
  • Applet is a sub class of java.applet.Applet class.
  • applet class will not define main () method.
  • java plug-in software is responsible to manage the applet life cycle.

Life Cycle of an applet :-

java.applet.Applet class

  • java.applet.Applet  class are provide 4 life cycle method.
  1. public void init()  :- this method is the first method to be called. it is initialized  the applet. this method is called only once time during the run time.
  2. public void start() :- start () are use to start the applet.
  3. public void stop() :-  stop () method is automatically called after when the user move off the page on applet site . it is used to stop the applet.
  4. public void destroy() :- destroy the applet.
  • init(), start(), stop(), destroy() method inherited from java.applet.Applet.

java.awt.Component class

  • java.awt.Component class are provide 1 life cycle method.
  1. public void paint() :- paint () method provide the graphics class object. its use to drwa rectangle, angle, square, line , oval, etc.

Create Applet :- 

import java.applet.Applet;
import java.awt.Graphics;
public class welcome extends Applet
{
public void paint(Graphics g)
{
g.drawString(“WELCOME”, 30, 30);
}
}