SlideShare a Scribd company logo
1 of 16
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

What's hot (20)

Java applets
Java appletsJava applets
Java applets
 
Applets
AppletsApplets
Applets
 
Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programming
 
ITFT- Applet in java
ITFT- Applet in javaITFT- Applet in java
ITFT- Applet in java
 
L18 applets
L18 appletsL18 applets
L18 applets
 
Java Applet
Java AppletJava Applet
Java Applet
 
Java Applets
Java AppletsJava Applets
Java Applets
 
Basics of applets.53
Basics of applets.53Basics of applets.53
Basics of applets.53
 
Lecture1 oopj
Lecture1 oopjLecture1 oopj
Lecture1 oopj
 
Appl clas nd architect.56
Appl clas nd architect.56Appl clas nd architect.56
Appl clas nd architect.56
 
Java applets
Java appletsJava applets
Java applets
 
27 applet programming
27  applet programming27  applet programming
27 applet programming
 
Java applet
Java appletJava applet
Java applet
 
Applet progming
Applet progmingApplet progming
Applet progming
 
Applet
AppletApplet
Applet
 
Java applet-basics
Java applet-basicsJava applet-basics
Java applet-basics
 
Java files and io streams
Java files and io streamsJava files and io streams
Java files and io streams
 
Applet init nd termination.59
Applet init nd termination.59Applet init nd termination.59
Applet init nd termination.59
 
Java applet-basics
Java applet-basicsJava applet-basics
Java applet-basics
 
Applet execution
Applet execution Applet execution
Applet execution
 

Similar to Applet Programming Guide: Learn How to Create Java Applets

Similar to Applet Programming Guide: Learn How to Create Java Applets (20)

Applets in Java
Applets in JavaApplets in Java
Applets in Java
 
Java applets
Java appletsJava applets
Java applets
 
applet.pptx
applet.pptxapplet.pptx
applet.pptx
 
Applet1 (1).pptx
Applet1 (1).pptxApplet1 (1).pptx
Applet1 (1).pptx
 
oops with java modules iii & iv.pptx
oops with java modules iii & iv.pptxoops with java modules iii & iv.pptx
oops with java modules iii & iv.pptx
 
Java applet
Java appletJava applet
Java applet
 
Java Applets
Java AppletsJava Applets
Java Applets
 
Smart material - Unit 3 (2).pdf
Smart material - Unit 3 (2).pdfSmart material - Unit 3 (2).pdf
Smart material - Unit 3 (2).pdf
 
Smart material - Unit 3 (1).pdf
Smart material - Unit 3 (1).pdfSmart material - Unit 3 (1).pdf
Smart material - Unit 3 (1).pdf
 
Applet.pptx
Applet.pptxApplet.pptx
Applet.pptx
 
UNIT-1-AJAVA.pdf
UNIT-1-AJAVA.pdfUNIT-1-AJAVA.pdf
UNIT-1-AJAVA.pdf
 
Advanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.pptAdvanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.ppt
 
3. applets
3. applets3. applets
3. applets
 
Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
 
Java: Java Applets
Java: Java AppletsJava: Java Applets
Java: Java Applets
 
Applet in java
Applet in javaApplet in java
Applet in java
 
Applet
 Applet Applet
Applet
 
Applets
AppletsApplets
Applets
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTION
 

More from janani thirupathi (17)

Networks
NetworksNetworks
Networks
 
Multimedia
MultimediaMultimedia
Multimedia
 
Data structure
Data structureData structure
Data structure
 
Dip
Dip Dip
Dip
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
data generalization and summarization
data generalization and summarization data generalization and summarization
data generalization and summarization
 
Data warehouse architecture
Data warehouse architecture Data warehouse architecture
Data warehouse architecture
 
Evolution of os
Evolution of osEvolution of os
Evolution of os
 
B tree
B  treeB  tree
B tree
 
File sharing
File sharingFile sharing
File sharing
 
Data transfer and manipulation
Data transfer and manipulationData transfer and manipulation
Data transfer and manipulation
 
Arithmetic Logic
Arithmetic LogicArithmetic Logic
Arithmetic Logic
 
Transaction management
Transaction managementTransaction management
Transaction management
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Memory System
Memory SystemMemory System
Memory System
 
Cn assignment
Cn assignmentCn assignment
Cn assignment
 
Narrowband ISDN
Narrowband ISDNNarrowband ISDN
Narrowband ISDN
 

Recently uploaded

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 

Recently uploaded (20)

OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 

Applet Programming Guide: Learn How to Create Java Applets

  • 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.