SlideShare a Scribd company logo
APPLET
By
M. Sri Nandhini
Introduction
 Applet is small java program that can be
easily transported over the network from
one computer to other.
 Used in internet applications.
 Embedded in an html page, can be
downloaded from the server and run on the
client, so as to do a specific kind of job.
 An applet is a program that runs in the
context of a browser session.
Applets, Webpage,
Client, Server
 Applets are programs stored on a web
server, similar to web pages.
 When an applet is referred to in a web page
that has been fetched and processed by a
browser, the browser generates a request
to fetch the applet program, the executes
the program in the browser’s execution
context on the client host.
Types of java programs
 Stand Alone Program
 Run on a single machine
 Compiler-javac
 Interpreter-java
 Web Based Program
 Compiler-javac
 Interpreter-applet viewer or web browser
 Must Subclass of Applet
 Import java.awt
Application vs Applet
Java Applications
• Stand-alone program
• Runs independently
• Has a main() method
• No HTML file
• Run using JDK’s
java interpreter
Java Applet
• Embedded program
• Runs in a Web
browser
• No main() method
• Requires an HTML
file
• Run using JDK’s
applet viewer.
Applet Class
Applet Example
import java.applet.*;
import java.awt.*;
public class FirstApplet extends applet{
public void paint(Graphics g)
{
g.drawString(“Hello World”,10,50);
}
}
Output
Applet Life Cycle
 An applet may move from one state to
another dependent upon a set of default
behaviours inherited in the form of methods
from ‘Applet’ class.
 These states are
 Born
 Running
 Idle
 Dead
Applet state diagram
Life Cycle of Applet
 Init()-
 Creates the objects needed by the applet
 Sets up initial values, load font and images or
set up colors.
 Called only once during the lifetime of an
applet.
 Start()-
 Moves to this phase automatically after the
initialization state.
 If the applet is stopped or it goes to idle state
start() method must be called in order to force
the applet again to the running state.
Life Cycle of Applet
Paint()-
 This method is called each time to draw
and redraw the output of an applet.
Stop()-
 Idle state, once it is stopped from
running.
 Destroy()-
 An applet goes to dead state when it is
destroyed by invoking the destroy() of
applet class.
 It results in complete removal of applet
from the memory.
Common Methods
 drawString()-
 Member of graphics class used to output a
string to an applet.
 It is typically called from within the paint() or
update() method.
 Void drawString(String msg,int a, int b).
 setBackground() & getBackground()-
 Belongs to component class used to set
and get the background color.
 Void setBackground(Color anyColor)
Common Methods
 Predefined constants for each color such as
Color.red can be used.
 setForeground()& getForeground()-
 Set and gets the color of the text to be
displayed on the foreground of the applet
window.
 Void setForeground(Color anyColor)
 showStatus()-
 Display any string In the status window of
the browser.
 Void showString(Stringtext).
Applet Execution
 An applet program is a written as a
subclass of the java. Applet class or the
javax.swing.Japplet class. There is no main
method: you must override the start
method. Applet objects uses AWT for
graphics. Japplet uses SWING.
 It is a graphics object that runs in a thread
object, so every applet can perform
graphics, and runs in parallel to the browser
process.
Applet Execution
When the applet is loaded,these methods are
automatically invoked in order:
 The init() method is invoked by the Java
Virtual Machine.
 The start() method.
 The paint()method.
 The applet is now running and rendered on
the web page.
Applet Security
For security reasons, applets that are loaded
over the network have several restrictions.
 An applet cannot ordinarily read or write
files on the computer that its executing on.
 An applet cannot make network
 connections except to the host that it came
from.
Summary
 An applet is a java class.
 Its code is downloaded from a web server.
 It is run in the browser’s environment on the
client host.
 It is invoked by a browser when it scans a
web page and encounters a class specified
with the APPLET tag. For security reason ,
the execution of an applet is normally
subject to restrictions:
 Applet cannot access files in the file system
on the client host.
 Applet cannot make network connection
exception to the server host from which it
originated.

More Related Content

What's hot

Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
amitksaha
 
Java applets
Java appletsJava applets
Java applets
lopjuan
 
L18 applets
L18 appletsL18 applets
L18 applets
teach4uin
 
ITFT- Applet in java
ITFT- Applet in javaITFT- Applet in java
ITFT- Applet in java
Atul Sehdev
 
Applet progming
Applet progmingApplet progming
Applet progming
VIKRANTHMALLIKARJUN
 
Java applet - java
Java applet - javaJava applet - java
Java applet - java
Rubaya Mim
 
Java Applet
Java AppletJava Applet
Java Applet
Athharul Haq
 
Java applet basics
Java applet basicsJava applet basics
Java applet basics
Sunil Pandey
 
Java applets
Java appletsJava applets
Java applets
Khan Mac-arther
 
Java applets
Java appletsJava applets
Java applets
M Vishnuvardhan Reddy
 
Java applets
Java appletsJava applets
Oop suplemnertary september 2019
Oop suplemnertary september  2019Oop suplemnertary september  2019
Oop suplemnertary september 2019
ktuonlinenotes
 
java applets
java appletsjava applets
java applets
Waheed Warraich
 
Applet init nd termination.59
Applet init nd termination.59Applet init nd termination.59
Applet init nd termination.59
myrajendra
 
Applet
AppletApplet
Applets in Java
Applets in JavaApplets in Java
Applets in Java
RamaPrabha24
 
Applet programming in java
Applet programming in javaApplet programming in java
Applet programming in java
Vidya Bharti
 
java Applet Introduction
java Applet Introductionjava Applet Introduction
java Applet Introduction
yugandhar vadlamudi
 
6.applet programming in java
6.applet programming in java6.applet programming in java
6.applet programming in java
Deepak Sharma
 
Applet programming
Applet programming Applet programming
Applet programming
Devyani Vaidya
 

What's hot (20)

Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
 
Java applets
Java appletsJava applets
Java applets
 
L18 applets
L18 appletsL18 applets
L18 applets
 
ITFT- Applet in java
ITFT- Applet in javaITFT- Applet in java
ITFT- Applet in java
 
Applet progming
Applet progmingApplet progming
Applet progming
 
Java applet - java
Java applet - javaJava applet - java
Java applet - java
 
Java Applet
Java AppletJava Applet
Java Applet
 
Java applet basics
Java applet basicsJava applet basics
Java applet basics
 
Java applets
Java appletsJava applets
Java applets
 
Java applets
Java appletsJava applets
Java applets
 
Java applets
Java appletsJava applets
Java applets
 
Oop suplemnertary september 2019
Oop suplemnertary september  2019Oop suplemnertary september  2019
Oop suplemnertary september 2019
 
java applets
java appletsjava applets
java applets
 
Applet init nd termination.59
Applet init nd termination.59Applet init nd termination.59
Applet init nd termination.59
 
Applet
AppletApplet
Applet
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
 
Applet programming in java
Applet programming in javaApplet programming in java
Applet programming in java
 
java Applet Introduction
java Applet Introductionjava Applet Introduction
java Applet Introduction
 
6.applet programming in java
6.applet programming in java6.applet programming in java
6.applet programming in java
 
Applet programming
Applet programming Applet programming
Applet programming
 

Similar to Applet (1)

Applet
AppletApplet
Applet
Amir Shokri
 
Java applet
Java appletJava applet
Java applet
Elizabeth alexander
 
Applets in java
Applets in javaApplets in java
Applets in java
Wani Zahoor
 
UNIT-1-AJAVA.pdf
UNIT-1-AJAVA.pdfUNIT-1-AJAVA.pdf
UNIT-1-AJAVA.pdf
PriyanshiPrajapati27
 
Java files and io streams
Java files and io streamsJava files and io streams
Java files and io streams
RubaNagarajan
 
Oops
OopsOops
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
Kuntal Bhowmick
 
Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01
Abhishek Khune
 
Appletjava
AppletjavaAppletjava
Appletjava
DEEPIKA T
 
Applet in java new
Applet in java newApplet in java new
Applet in java new
Kavitha713564
 
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
Kuntal Bhowmick
 
Basic of Applet
Basic of AppletBasic of Applet
Basic of Applet
suraj pandey
 
Advanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.pptAdvanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.ppt
miki304759
 
applet.pptx
applet.pptxapplet.pptx
applet.pptx
SachinBhosale73
 
Lecture1 oopj
Lecture1 oopjLecture1 oopj
Lecture1 oopj
Dhairya Joshi
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
mcanotes
 
Applet1 (1).pptx
Applet1 (1).pptxApplet1 (1).pptx
Applet1 (1).pptx
FahanaAbdulVahab
 
Applet Life Cycle in Java with brief introduction
Applet Life Cycle in Java with brief introductionApplet Life Cycle in Java with brief introduction
Applet Life Cycle in Java with brief introduction
devicse
 
Java applet-basics
Java applet-basicsJava applet-basics
Java applet-basics
kanchanmahajan23
 
APPLET.pptx
APPLET.pptxAPPLET.pptx

Similar to Applet (1) (20)

Applet
AppletApplet
Applet
 
Java applet
Java appletJava applet
Java applet
 
Applets in java
Applets in javaApplets in java
Applets in java
 
UNIT-1-AJAVA.pdf
UNIT-1-AJAVA.pdfUNIT-1-AJAVA.pdf
UNIT-1-AJAVA.pdf
 
Java files and io streams
Java files and io streamsJava files and io streams
Java files and io streams
 
Oops
OopsOops
Oops
 
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
 
Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01
 
Appletjava
AppletjavaAppletjava
Appletjava
 
Applet in java new
Applet in java newApplet in java new
Applet in java new
 
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
 
Basic of Applet
Basic of AppletBasic of Applet
Basic of Applet
 
Advanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.pptAdvanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.ppt
 
applet.pptx
applet.pptxapplet.pptx
applet.pptx
 
Lecture1 oopj
Lecture1 oopjLecture1 oopj
Lecture1 oopj
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
 
Applet1 (1).pptx
Applet1 (1).pptxApplet1 (1).pptx
Applet1 (1).pptx
 
Applet Life Cycle in Java with brief introduction
Applet Life Cycle in Java with brief introductionApplet Life Cycle in Java with brief introduction
Applet Life Cycle in Java with brief introduction
 
Java applet-basics
Java applet-basicsJava applet-basics
Java applet-basics
 
APPLET.pptx
APPLET.pptxAPPLET.pptx
APPLET.pptx
 

More from DEEPIKA T

71619109 configuration-management.pdf (1) (1)
71619109 configuration-management.pdf (1) (1)71619109 configuration-management.pdf (1) (1)
71619109 configuration-management.pdf (1) (1)
DEEPIKA T
 
80068
8006880068
80068
DEEPIKA T
 
242296
242296242296
242296
DEEPIKA T
 
Data mining
Data miningData mining
Data mining
DEEPIKA T
 
Parallelizing matrix multiplication
Parallelizing  matrix multiplicationParallelizing  matrix multiplication
Parallelizing matrix multiplication
DEEPIKA T
 
Health care in big data analytics
Health care in big data analyticsHealth care in big data analytics
Health care in big data analytics
DEEPIKA T
 
Ajax
AjaxAjax
Ajax
DEEPIKA T
 
Role of human interaction
Role of human interactionRole of human interaction
Role of human interaction
DEEPIKA T
 
Basic analtyics & advanced analtyics
Basic analtyics & advanced analtyicsBasic analtyics & advanced analtyics
Basic analtyics & advanced analtyics
DEEPIKA T
 
Soap,Rest&Json
Soap,Rest&JsonSoap,Rest&Json
Soap,Rest&Json
DEEPIKA T
 
Jdbc ja
Jdbc jaJdbc ja
Jdbc ja
DEEPIKA T
 
Remote method invocation
Remote  method invocationRemote  method invocation
Remote method invocation
DEEPIKA T
 
Graph representation
Graph representationGraph representation
Graph representation
DEEPIKA T
 
Al
AlAl
Presentation2
Presentation2Presentation2
Presentation2
DEEPIKA T
 
Depth first search [dfs]
Depth first search [dfs]Depth first search [dfs]
Depth first search [dfs]
DEEPIKA T
 
Topological sort
Topological sortTopological sort
Topological sort
DEEPIKA T
 
Path compression
Path compressionPath compression
Path compression
DEEPIKA T
 
Genetic representation
Genetic representationGenetic representation
Genetic representation
DEEPIKA T
 

More from DEEPIKA T (20)

See
SeeSee
See
 
71619109 configuration-management.pdf (1) (1)
71619109 configuration-management.pdf (1) (1)71619109 configuration-management.pdf (1) (1)
71619109 configuration-management.pdf (1) (1)
 
80068
8006880068
80068
 
242296
242296242296
242296
 
Data mining
Data miningData mining
Data mining
 
Parallelizing matrix multiplication
Parallelizing  matrix multiplicationParallelizing  matrix multiplication
Parallelizing matrix multiplication
 
Health care in big data analytics
Health care in big data analyticsHealth care in big data analytics
Health care in big data analytics
 
Ajax
AjaxAjax
Ajax
 
Role of human interaction
Role of human interactionRole of human interaction
Role of human interaction
 
Basic analtyics & advanced analtyics
Basic analtyics & advanced analtyicsBasic analtyics & advanced analtyics
Basic analtyics & advanced analtyics
 
Soap,Rest&Json
Soap,Rest&JsonSoap,Rest&Json
Soap,Rest&Json
 
Jdbc ja
Jdbc jaJdbc ja
Jdbc ja
 
Remote method invocation
Remote  method invocationRemote  method invocation
Remote method invocation
 
Graph representation
Graph representationGraph representation
Graph representation
 
Al
AlAl
Al
 
Presentation2
Presentation2Presentation2
Presentation2
 
Depth first search [dfs]
Depth first search [dfs]Depth first search [dfs]
Depth first search [dfs]
 
Topological sort
Topological sortTopological sort
Topological sort
 
Path compression
Path compressionPath compression
Path compression
 
Genetic representation
Genetic representationGenetic representation
Genetic representation
 

Recently uploaded

Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
ArianaBusciglio
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 

Recently uploaded (20)

Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 

Applet (1)

  • 2. Introduction  Applet is small java program that can be easily transported over the network from one computer to other.  Used in internet applications.  Embedded in an html page, can be downloaded from the server and run on the client, so as to do a specific kind of job.  An applet is a program that runs in the context of a browser session.
  • 3. Applets, Webpage, Client, Server  Applets are programs stored on a web server, similar to web pages.  When an applet is referred to in a web page that has been fetched and processed by a browser, the browser generates a request to fetch the applet program, the executes the program in the browser’s execution context on the client host.
  • 4. Types of java programs  Stand Alone Program  Run on a single machine  Compiler-javac  Interpreter-java  Web Based Program  Compiler-javac  Interpreter-applet viewer or web browser  Must Subclass of Applet  Import java.awt
  • 5. Application vs Applet Java Applications • Stand-alone program • Runs independently • Has a main() method • No HTML file • Run using JDK’s java interpreter Java Applet • Embedded program • Runs in a Web browser • No main() method • Requires an HTML file • Run using JDK’s applet viewer.
  • 7. Applet Example import java.applet.*; import java.awt.*; public class FirstApplet extends applet{ public void paint(Graphics g) { g.drawString(“Hello World”,10,50); } }
  • 9. Applet Life Cycle  An applet may move from one state to another dependent upon a set of default behaviours inherited in the form of methods from ‘Applet’ class.  These states are  Born  Running  Idle  Dead
  • 11. Life Cycle of Applet  Init()-  Creates the objects needed by the applet  Sets up initial values, load font and images or set up colors.  Called only once during the lifetime of an applet.  Start()-  Moves to this phase automatically after the initialization state.  If the applet is stopped or it goes to idle state start() method must be called in order to force the applet again to the running state.
  • 12. Life Cycle of Applet Paint()-  This method is called each time to draw and redraw the output of an applet. Stop()-  Idle state, once it is stopped from running.  Destroy()-  An applet goes to dead state when it is destroyed by invoking the destroy() of applet class.  It results in complete removal of applet from the memory.
  • 13. Common Methods  drawString()-  Member of graphics class used to output a string to an applet.  It is typically called from within the paint() or update() method.  Void drawString(String msg,int a, int b).  setBackground() & getBackground()-  Belongs to component class used to set and get the background color.  Void setBackground(Color anyColor)
  • 14. Common Methods  Predefined constants for each color such as Color.red can be used.  setForeground()& getForeground()-  Set and gets the color of the text to be displayed on the foreground of the applet window.  Void setForeground(Color anyColor)  showStatus()-  Display any string In the status window of the browser.  Void showString(Stringtext).
  • 15. Applet Execution  An applet program is a written as a subclass of the java. Applet class or the javax.swing.Japplet class. There is no main method: you must override the start method. Applet objects uses AWT for graphics. Japplet uses SWING.  It is a graphics object that runs in a thread object, so every applet can perform graphics, and runs in parallel to the browser process.
  • 16. Applet Execution When the applet is loaded,these methods are automatically invoked in order:  The init() method is invoked by the Java Virtual Machine.  The start() method.  The paint()method.  The applet is now running and rendered on the web page.
  • 17. Applet Security For security reasons, applets that are loaded over the network have several restrictions.  An applet cannot ordinarily read or write files on the computer that its executing on.  An applet cannot make network  connections except to the host that it came from.
  • 18. Summary  An applet is a java class.  Its code is downloaded from a web server.  It is run in the browser’s environment on the client host.  It is invoked by a browser when it scans a web page and encounters a class specified with the APPLET tag. For security reason , the execution of an applet is normally subject to restrictions:
  • 19.  Applet cannot access files in the file system on the client host.  Applet cannot make network connection exception to the server host from which it originated.