Applet Java 5
Applet Java 5
UNIT-V
Applets, local and remote applets, applets VS
applications, writing applets, applets life cycle,
creating an executable applet, designing a web page,
applet tag, adding applet to HTML file,
running the applet, passing parameters to applets,
aligning the display, HTML tags & applets,
getting input from the user interface.
Applets:
An applet is a special Java program that runs in a browser
enabled with Java technology (JRE) that can be downloaded
from the internet and run. An applet is typically embedded
inside a HTML page and runs in the context of a browser. An
applet is designed to run remotely in the client browser, so
there are some restrictions on it. The applet can't access
system resources on the local computer. Applets are used to
make the web site more dynamic and entertaining. An applet
must be a subclass of the java.applet.Applet class. The Applet
class provides the standard interface between the applet and
the browser environment.
Features of Java Applet :
It requires a Java-supported web browser for its execution.
All the Java applets are a sub-class of the
java.applet.Applet class.
main() method is not required
it follows this sequence while executing methods : init(),
start(), paint() and then other methods.
Termination of a Java applet is done by stop() and
destroy() methods.
It is used to display dynamic content.
JAVA
UNIT-V
local and remote applets:
Local Applet is written on our own, and then we will embed
it into web pages. Local Applet is developed locally and
stored in the local system. A web page doesn't need the
get the information from the internet when it finds the
local Applet in the system. It is specified or defined by the
file name or pathname. There are two attributes used in
defining an applet, i.e., the codebase that specifies the
path name and code that defined the name of the file that
contains Applet's code.
<applet
codebase = "tictactoe"
code = "FaceApplet.class" width = 120
height = 120> </applet>
Java Application
1.A Java Application is a Java program that runs on the
system with the help of JVM.
2.For executing a Java application we require a main()
method that calls other methods or it has other
instructions.
3.Java applications are compiled and executed with the
help of the Java compiler (Java virtual machine).
4.For the execution of Java Application, it needs to be
saved in the file system of the computer.
5.It needs JRE (Java Runtime Environment) to execute.
JAVA
UNIT-V
Life Cycle Of An Applet :
These are the different stages involved in the life cycle of
an applet.
Initialization State
Running State
Idle or stopped state
Dead State
Display State
JAVA
UNIT-V
Initial ization State
The l ife cycl e of an appl et begins when the appl et i s f i rs t l oaded
into the browser and cal l ed the i ni t( ) method . A nd the i ni t( )
method is cal l ed exactl y once i n an appl et's l i f e when appl et i s
first l oaded. Basical l y t he pur pos e of t he ini t( ) method i s to read
the PARAM tag in the HTML f i l e. It is r etri ev i ng the parameters i n
the param tag.
Syntax
Running State
This state is the second s tage of the appl et l i f e cycl e. A f ter
initial ization, this stat e wi l l automat i cal l y occur by i nv oki ng the
start method of the appl et c l as s whi ch agai n cal l s the run m ethod
and which cal l s the pa i nt method. And i t can occur f rom the Id l e
State when the appl et is r el oaded. Thi s method runs mul ti pl e
times.
Syntax
Syntax
Dead State
This state is the fourt h s tage of the appl et l i f e cycl e. When the
appl et program terminates , the des troy f uncti on i s i nv oked whi ch
makes an appl et to be i n the Dead State. Thi s s tage occurs when
the destroy() method is c al l ed. And thi s method i s cal l ed onl y one
time in the whol e l ife cycl e.
Syntax
Syntax