Professional Documents
Culture Documents
Interactive Java Note - M06 - UN11 - P01
Interactive Java Note - M06 - UN11 - P01
Presentation 1
Revision
Objectives
At the end of this presentation, you will be able to : Explain applet programming List the differences between applications and applets Describe the different stages in the life cycle of an applet
Java Programs
Java supports two kinds of programs.
Java Applications are the normal standalone programs.
Java Applets are the programs that are to be embedded in a Web page.
Applet Programming
Applets are the Java programs that are executed by the Web browser.
Appletviewer is a Java utility to execute applets. Applet is a special class file written to display graphics in a Web browser.
Applets
Applets are embedded in Web pages using the HTML tag <APPLET>.
When a Web page containing applet program is run, it is downloaded to the memory automatically and executed by the Web browser. Applet gets displayed in the specific space allocated in the Web page called Applet Window.
Applets
Applets can contain embedded objects like :
Animated graphics Video games Advanced text displays and images Audio
Applet Types
Local Applets
Remote Applets
Applets that are stored in a remote computer. These can be downloaded and embedded into Web pages from the Internet.
Local Applets
Remote Applets
init()
Initialisation State
This method is executed when it is first loaded into the memory.
init()
Syntax
start()
Running State
The start() method of the Applet Class is executed whenever an applet is started or restarted. The applet is now said to exist in the running state.
start()
Syntax
stop()
Idle State
The stop() method is executed when an applet is closed. The applet is stopped automatically when the user switches to another program or Web page. This can also be done by invoking explicitly the stop() method of Applet class. When this is invoked the applet enters the idle state.
stop()
Syntax
destroy()
Dead State
The destroy() method is executed when a Web page is closed.
destroy()
Syntax
paint()
The paint() method of the Applet class is executed automatically whenever the applet is displayed in the Web page. This method is used to draw graphics in the drawing area of the applet.
repaint()
The repaint() method is used whenever you want to redraw the applets drawing area. The repaint() method calls the update() method. The update() method clears the applet area and calls the paint() method.
paint()
Syntax
Summary
In this presentation, you learnt the following Applets are Java programs mainly used in Internet computing.
The applets output is displayed within a subset of the display area of the browser.
Java applet inherits a set of default properties from the Applet class. An applet enters the Initialisation state when it is first loaded.
Summary
In this presentation, you learnt the following Applet enters the running state when the start() method of Applet class is invoked. An applet becomes idle when it is stopped from running.
Assignment
1. Define an applet. List the uses of applets. 2. Sketch and explain the life cycle of an applet.