Module8 Applet
Module8 Applet
Types of applet
Local applet: An applet developed locally and stored in a local system is
known as a local applet.
Remote applet: A remote applet is that which is developed by someone else
and stored on a remote computer connected to the Internet.
init(): The init() method is the first method to run that initializes the applet.
It can be invoked only once at the time of initialization.
start(): The start() method contains the actual code of the applet and starts
the applet. It is invoked immediately after the init() method is invoked.
Every time the browser is loaded or refreshed, the start() method is invoked.
stop(): The stop() method stops the execution of the applet. The stop ()
method is invoked whenever the applet is stopped, minimized, or moving
from one tab to another in the browser, the stop() method is invoked.
destroy(): The destroy() method destroys the applet after its work is done. It
is invoked when the applet window is closed or when the tab containing the
webpage is closed.
paint(): The paint() method belongs to the Graphics class in Java. It is used
to draw shapes like circle, square, trapezium, etc., in the applet. It is
executed after the start() method and when the browser or applet windows
are resized.
example:-
import java.applet.*;
import java.awt.*;
class abc extends Applet
{
public void paint(Graphics g)
{
g.setColor(Color.red);
g.drawRect(100,100,50,70);
g.setColor(Color.green);
g.fillOval(300,300,50,50);
}
}