Professional Documents
Culture Documents
Programming
Chapter-5
Marks-20
Introduction
• There are two kinds of Java programs-
–Applications (stand-alone programs)
–Applets.
Internet
• start() :
– This method is automatically called after Java calls
the init method.
• stop() :
– This method is automatically called when the user
moves off the page where the applet sits.
• destroy():
– Java calls this method when the browser shuts
down.
paint() Method of Applet Class
• Paint method actually displays the result of applet
code on the screen.
• The output may be text, graphics, or sound.
• Syntax-
public void paint(Graphics g)
• The paint method requires graphics object as an
argument.
• Hence we require to import Graphics class from
java.awt package.
Applet Life Cycle
Begin
(Load applet) Born Initialization
start()
stop()
Display start()
destroy()
paint()
Destroyed Dead End
Exit browser
<applet ……>
<param name=“color” value=“RED”>
Passing Parameters to Applet
• To handle parameters, we need to do two things.
1) Include <param.....> tags in HTML document.
2) Provide code in the applet to pass these parameters.