Java Applets
Java Applets
Java Programming
Java Applet
Java Applet
2
What is Applet?
Applets are used to make the website more dynamic and entertaining.
Applets are not stand-alone programs. Instead, they run within either a web
browser or an applet viewer. JDK provides a standard applet viewer tool
called applet viewer.
Java Applet
3
init( ) :
The init( ) method is the first method to be called. This is where you should
initialize variables. This method is called only once during the run time of
your applet.
start () −
This method is automatically called after the browser calls the init method. It
is also called whenever the user returns to the page containing the applet after
having gone off to other pages.
Stop() − This method is automatically called when the user moves off the
page on which the applet sits. It can, therefore, be called repeatedly in the
same applet.
Java Applet
7
destroy ()−
This method is only called when the browser shuts down normally. Because
applets are meant to live on an HTML page, you should not normally leave
resources behind after a user leaves the page that contains the applet.
paint ()−
Invoked immediately after the start() method, and also any time the applet
needs to repaint itself in the browser. The paint() method is actually inherited
from the java.awt.
Java Applet
8
Java Applet
9
Java Applet
10
Java Applet
11
Java Applet
12