Applets
Applets
Applets
Definition
• It is a small application that is embedded in a
HTML page, which is accessed and
transported over the internet, automatically
installed into the client machines and run as a
part of a web page.
Uses of Applets
• Applets are used for creating dynamic and
interactive web applications.
• They can be used to provide dynamic user
interfaces and graphical effects for web pages.
• They are used to add user interfaces like
buttons, text boxes, images etc.
• It can also be used in animations, games and
text editors.
How applets gets executed?
• Create the programs ,compile it and obtain
the byte code.
• This byte code is embedded in HTML page.
• This HTML page can be viewed using web
browsers.
• Browser will execute the applets byte code
using applet engine.
How to run an applet?
here are two ways to run an applet
• By html file.
• By appletViewer tool (for testing purpose
Hierarchy of applet
object
component
container
panel
Applet
Difference between applet program and
application program
Applets Applications
1.They do not have main() method Applications have main () method
2.They run under the control of web Get executed independently
browsers
3.They executed in java browser or applet They can be executed in java interpreters
viewer.
4.They cannot run any programs in the 4.They can run other programs in the local
local computers. computers.
5.They cannot use libraries from other They can use libraries from other
languages. languages.
6.They can be embedded into HTML They can not be embedded with HTML
pages. pages.
Applet Life Cycle
Born
Idle
running
Dead
Applet Life Cycle
Advantages:
• It works at client side so less response time.
• Secured
• It can be executed by browsers running under
many platforms, including Linux, Windows, Mac Os
etc.
Disadvantages:
• Plugin is required at client browser to execute
applet.
Program 20: Program to Demonstrate Applet Life Cycle
MyApplet.html