SlideShare a Scribd company logo
Applet Programming
Presented By,
T. Janani
II-M.SC(CS&IT)
Nadar Saraswathi
College Of Arts & Science, Theni.
Applet Programming:
 Applet are small java program that are embedded in
web pages.
 They can be transported over the Internet from one
computer(web server) to another(client computers).
 They transform web into rich media and support the
delivery of applications via the Internet
 An Applet can be a fully functional Java application
because it has the entire Java API as its disposal.
There are certain difference between Applet and Java standalone
Application that are described below:
1. An Applet is a Java class that extends the
java.applet.Applet class.
2. A main () method is not invoke on an applet, and an
applet class will not define main().
3. Applets are designed to be embedded within an
HTML page.
4. When an user views a HTML page that contains an
applet, the code for the applet is downloaded to the user’s machine.
5. A JVM is required to view an applet. The JVM can be
either a plug-in of the Web browser or a separate runtime
environment.
6. The JVM on the user’s machine creates an instance
of the applet class and invokes various methods during the applet’s
lifetime.
7. Applets have strict security rules that are enforced by
the Web browser.
8. The security of an applet is often referred to as
sandbox security, comparing the applet to a child playing in a sandbox
with various rules that must be allowed..
Life Cycle Of Applet:
Applet Initialized Applet Running
Applet Destroyed Applet Stopped
Init() Start()
Start() Stop()
Destroy()
Different methods that are used in Applet Life Cycle:
1. init()Method: This method is intended for
whatever initialization is needed for your applet. It is called after the
Param tags inside the applet tag have been processed.
2. Start()Method: This method is automatically called
after the browser calls the init() method. It is called whenever the
user returns to the page containing the applet after having gone off
to other pages.
3. Stop()Method: 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.
4. destroy()Method: 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.
5. paint()Method: Invoked immediately after the
Start()method, and also any time the applet needs to repaint itself to
repaint itself in the browser. The paint()method is actually
inherited from the java.awt.
Simple Example to Create an Applet Program
To create an Applet program follow the steps:
1. Create a Java file containing Applet Code and Methods
described above
2. Create a HTML file and embed the .Class File of the Java
file created in the first step
3. Run Applet using either of the following methods
 Open the HTML file in the java enable web
browser
 Use AppletViewer tool(used only for testing
purpose)
Creating an Executable Applet
 Executable applet is nothing but the .Class file of
apple, which is obtained by compiling the source
code o the applet. Compiling the applet is exactly
the same as compiling an application using
following command.
javac appletname.java
 The compiled output file called appletname.class
should be placed in the same directory as the
source file.
Designing a web page
 Java applet are program that reside on web page. A
web page basically made up of text and HTML tags that
can be interpreted by a web browser or an applet
viewer.
 A web page is also called HTML page or HTML
document. Web pages are stored using a ile extension
.html such as my Applet.html.
 A web page is marked by an opening HTML
tag<HTML> and closing HTML tag </HTML>and is
divided into the following three major parts:
1) Comment Section
2) Head Section
3) Body Section
1) Comment Section:
This is very first section of any web page
containing the comments about the web page
functionality.
It is important to include comments that tell us
what is going on in the web page.
A comment line begins with <! And ends with a
> and the web browsers will ignore the text
enclosed between them.
The comments are optional and can be included
anywhere in the web page.
2) Head Section
This section contains title, heading and sub heading
of the web page. The head section is defined with a starting <Head>
tag and closing</Head>tag.
<Head>
<Title>Welcome to Java Applet</Title>
</Head>
3) Body Section
After the Head Section the body section comes. This
is called as body section because the entire information and behavior
of the web page is contained in it,
It describes the color, location, sound etc. of the data
or information that is going to be placed in the web page.
<Body>
<Center>
<H1>
Welcome to Java
</H1>
</Center>
<BR>
<APPLET-->
</APPLET>
</Body>
Applet Tag
 The <Applet..> tag supplies the name of the applet
to be loaded and tells the browser how much space
the applet requires.
 The ellipsis in the tag <Applet..> tag given below
specifies the minimum requirements to place the
Hellojava applet on a web page.
<Applet
code=Hellojava .class
width=400
Height=200>
</Applet>
The applet tag discussed above specified the three things:
1) Name of the applet
2) Width of the applet(in pixels)
3) Height of the applet(in pixels)
Running the Applet:
To execute the applet with an applet viewer, you may
also execute the HTML file in which it is enclosed.
Example:
c:>appletviewer RunApp.html
Execute the applet the applet viewer, specifying the
name of your applet’s source file. The applet viewer will encounter the
applet tag within the comment and execute your applet.
Thank You

More Related Content

PPTX
Appletjava
PDF
Java applets and working principles
PPT
Java applet
PPT
Java Applet
PDF
Java applet basics
PDF
Class notes(week 10) on applet programming
PPT
Java applets
PPTX
Applet programming in java
Appletjava
Java applets and working principles
Java applet
Java Applet
Java applet basics
Class notes(week 10) on applet programming
Java applets
Applet programming in java

What's hot (19)

PPS
ODP
Applets
DOCX
Class notes(week 10) on applet programming
PDF
ITFT- Applet in java
PPTX
L18 applets
PPTX
Java Applets
PPT
Basics of applets.53
DOCX
Lecture1 oopj
PPT
Appl clas nd architect.56
PPT
Java applets
PDF
27 applet programming
PPTX
Java applet
PPTX
Applet progming
DOCX
Java applet-basics
PPT
Java files and io streams
PPT
Applet init nd termination.59
PDF
Java applet-basics
PPT
Applet execution
Applets
Class notes(week 10) on applet programming
ITFT- Applet in java
L18 applets
Java Applets
Basics of applets.53
Lecture1 oopj
Appl clas nd architect.56
Java applets
27 applet programming
Java applet
Applet progming
Java applet-basics
Java files and io streams
Applet init nd termination.59
Java applet-basics
Applet execution
Ad

Similar to Java (20)

PPTX
MSBTE Computer Engineering Java applet.pptx
PPTX
Applet1 (1).pptx
PPTX
Applets in Java. Learn java program with applets
PPTX
applet.pptx
PPT
Slide8appletv2 091028110313-phpapp01
PPTX
Applet intro
PPTX
Java applet
PPTX
Applets in Java
PPT
Java: Java Applets
PPTX
Applet.pptx
PPTX
Introduction To Applets methods and simple examples
PPT
JAVA APPLET BASICS
DOC
Applet
PPT
Jsp applet
PPTX
PPT
Applet and graphics programming
PPTX
Applet
PDF
PPT
171-33B - Java Programming-Building Applets.ppt
PPTX
Applet Programming in Advance Java Programming
MSBTE Computer Engineering Java applet.pptx
Applet1 (1).pptx
Applets in Java. Learn java program with applets
applet.pptx
Slide8appletv2 091028110313-phpapp01
Applet intro
Java applet
Applets in Java
Java: Java Applets
Applet.pptx
Introduction To Applets methods and simple examples
JAVA APPLET BASICS
Applet
Jsp applet
Applet and graphics programming
Applet
171-33B - Java Programming-Building Applets.ppt
Applet Programming in Advance Java Programming
Ad

More from janani thirupathi (17)

PPTX
PPTX
Multimedia
PPTX
Data structure
PPTX
Software Engineering
PPTX
data generalization and summarization
PPTX
Data warehouse architecture
PPTX
Evolution of os
PPTX
PPTX
File sharing
PPTX
Data transfer and manipulation
PPTX
Arithmetic Logic
PPTX
Transaction management
PPTX
Programming in c Arrays
PPTX
Memory System
PPTX
Cn assignment
PPTX
Narrowband ISDN
Multimedia
Data structure
Software Engineering
data generalization and summarization
Data warehouse architecture
Evolution of os
File sharing
Data transfer and manipulation
Arithmetic Logic
Transaction management
Programming in c Arrays
Memory System
Cn assignment
Narrowband ISDN

Recently uploaded (20)

PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Institutional Correction lecture only . . .
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Business Ethics Teaching Materials for college
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
Classroom Observation Tools for Teachers
PDF
Insiders guide to clinical Medicine.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
O5-L3 Freight Transport Ops (International) V1.pdf
Institutional Correction lecture only . . .
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
human mycosis Human fungal infections are called human mycosis..pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Business Ethics Teaching Materials for college
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
TR - Agricultural Crops Production NC III.pdf
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
RMMM.pdf make it easy to upload and study
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Cell Structure & Organelles in detailed.
Classroom Observation Tools for Teachers
Insiders guide to clinical Medicine.pdf
O7-L3 Supply Chain Operations - ICLT Program
102 student loan defaulters named and shamed – Is someone you know on the list?
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester

Java

  • 1. Applet Programming Presented By, T. Janani II-M.SC(CS&IT) Nadar Saraswathi College Of Arts & Science, Theni.
  • 2. Applet Programming:  Applet are small java program that are embedded in web pages.  They can be transported over the Internet from one computer(web server) to another(client computers).  They transform web into rich media and support the delivery of applications via the Internet  An Applet can be a fully functional Java application because it has the entire Java API as its disposal.
  • 3. There are certain difference between Applet and Java standalone Application that are described below: 1. An Applet is a Java class that extends the java.applet.Applet class. 2. A main () method is not invoke on an applet, and an applet class will not define main(). 3. Applets are designed to be embedded within an HTML page. 4. When an user views a HTML page that contains an applet, the code for the applet is downloaded to the user’s machine.
  • 4. 5. A JVM is required to view an applet. The JVM can be either a plug-in of the Web browser or a separate runtime environment. 6. The JVM on the user’s machine creates an instance of the applet class and invokes various methods during the applet’s lifetime. 7. Applets have strict security rules that are enforced by the Web browser. 8. The security of an applet is often referred to as sandbox security, comparing the applet to a child playing in a sandbox with various rules that must be allowed..
  • 5. Life Cycle Of Applet: Applet Initialized Applet Running Applet Destroyed Applet Stopped Init() Start() Start() Stop() Destroy()
  • 6. Different methods that are used in Applet Life Cycle: 1. init()Method: This method is intended for whatever initialization is needed for your applet. It is called after the Param tags inside the applet tag have been processed. 2. Start()Method: This method is automatically called after the browser calls the init() method. It is called whenever the user returns to the page containing the applet after having gone off to other pages. 3. Stop()Method: 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.
  • 7. 4. destroy()Method: 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. 5. paint()Method: Invoked immediately after the Start()method, and also any time the applet needs to repaint itself to repaint itself in the browser. The paint()method is actually inherited from the java.awt.
  • 8. Simple Example to Create an Applet Program To create an Applet program follow the steps: 1. Create a Java file containing Applet Code and Methods described above 2. Create a HTML file and embed the .Class File of the Java file created in the first step 3. Run Applet using either of the following methods  Open the HTML file in the java enable web browser  Use AppletViewer tool(used only for testing purpose)
  • 9. Creating an Executable Applet  Executable applet is nothing but the .Class file of apple, which is obtained by compiling the source code o the applet. Compiling the applet is exactly the same as compiling an application using following command. javac appletname.java  The compiled output file called appletname.class should be placed in the same directory as the source file.
  • 10. Designing a web page  Java applet are program that reside on web page. A web page basically made up of text and HTML tags that can be interpreted by a web browser or an applet viewer.  A web page is also called HTML page or HTML document. Web pages are stored using a ile extension .html such as my Applet.html.  A web page is marked by an opening HTML tag<HTML> and closing HTML tag </HTML>and is divided into the following three major parts: 1) Comment Section 2) Head Section 3) Body Section
  • 11. 1) Comment Section: This is very first section of any web page containing the comments about the web page functionality. It is important to include comments that tell us what is going on in the web page. A comment line begins with <! And ends with a > and the web browsers will ignore the text enclosed between them. The comments are optional and can be included anywhere in the web page.
  • 12. 2) Head Section This section contains title, heading and sub heading of the web page. The head section is defined with a starting <Head> tag and closing</Head>tag. <Head> <Title>Welcome to Java Applet</Title> </Head> 3) Body Section After the Head Section the body section comes. This is called as body section because the entire information and behavior of the web page is contained in it,
  • 13. It describes the color, location, sound etc. of the data or information that is going to be placed in the web page. <Body> <Center> <H1> Welcome to Java </H1> </Center> <BR> <APPLET--> </APPLET> </Body>
  • 14. Applet Tag  The <Applet..> tag supplies the name of the applet to be loaded and tells the browser how much space the applet requires.  The ellipsis in the tag <Applet..> tag given below specifies the minimum requirements to place the Hellojava applet on a web page. <Applet code=Hellojava .class width=400 Height=200> </Applet>
  • 15. The applet tag discussed above specified the three things: 1) Name of the applet 2) Width of the applet(in pixels) 3) Height of the applet(in pixels) Running the Applet: To execute the applet with an applet viewer, you may also execute the HTML file in which it is enclosed. Example: c:>appletviewer RunApp.html Execute the applet the applet viewer, specifying the name of your applet’s source file. The applet viewer will encounter the applet tag within the comment and execute your applet.