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

PPTX
Java Programming- Introduction to Java Applet Programs
PPS
PPTX
Java Applets
PPT
Appl clas nd architect.56
PDF
27 applet programming
PPTX
Java applets
PPT
Java applet
Java Programming- Introduction to Java Applet Programs
Java Applets
Appl clas nd architect.56
27 applet programming
Java applets
Java applet

What's hot (20)

PPT
Applet Architecture - Introducing Java Applets
PPT
Java applets
PPTX
L18 applets
PDF
ITFT- Applet in java
PPTX
Applet progming
PPTX
Java applet - java
PPT
Java Applet
PDF
Java applet basics
PPT
Java applets
PPT
Java applets
PDF
Oop suplemnertary september 2019
PPT
java applets
PPT
Applet init nd termination.59
PPTX
PPTX
Applets in Java
PPTX
Applet programming in java
PPTX
java Applet Introduction
PPTX
6.applet programming in java
PPTX
Applet programming
Applet Architecture - Introducing Java Applets
Java applets
L18 applets
ITFT- Applet in java
Applet progming
Java applet - java
Java Applet
Java applet basics
Java applets
Java applets
Oop suplemnertary september 2019
java applets
Applet init nd termination.59
Applets in Java
Applet programming in java
java Applet Introduction
6.applet programming in java
Applet programming
Ad

Similar to Applet (1) (20)

PPTX
Applets in java
PPT
Applet and graphics programming
PPTX
Appletjava
PPT
Basic of Applet
PPTX
Introduction To Applets methods and simple examples
PPTX
Applets in Java
PPT
Advanced Programming, Java Programming, Applets.ppt
PPTX
applet.pptx
PPTX
Applet1 (1).pptx
PPTX
PPTX
MSBTE Computer Engineering Java applet.pptx
PPSX
Java Applet
PDF
Java applet programming concepts
PPT
Slide8appletv2 091028110313-phpapp01
PPTX
Java applet
PDF
PDF
Class notes(week 10) on applet programming
PPT
Java programming Java programming Java programming
PPTX
Applets
PPTX
Applets in Java. Learn java program with applets
Applets in java
Applet and graphics programming
Appletjava
Basic of Applet
Introduction To Applets methods and simple examples
Applets in Java
Advanced Programming, Java Programming, Applets.ppt
applet.pptx
Applet1 (1).pptx
MSBTE Computer Engineering Java applet.pptx
Java Applet
Java applet programming concepts
Slide8appletv2 091028110313-phpapp01
Java applet
Class notes(week 10) on applet programming
Java programming Java programming Java programming
Applets
Applets in Java. Learn java program with applets
Ad

More from DEEPIKA T (20)

PDF
PDF
71619109 configuration-management.pdf (1) (1)
PPTX
80068
PPTX
242296
PPTX
Data mining
PPTX
Parallelizing matrix multiplication
PPTX
Health care in big data analytics
PPTX
Ajax
PPTX
Role of human interaction
PPTX
Basic analtyics & advanced analtyics
PPTX
Soap,Rest&Json
PPTX
Jdbc ja
PPTX
Remote method invocation
PPTX
Graph representation
PPTX
PPTX
Presentation2
PPTX
Depth first search [dfs]
PPTX
Topological sort
PPTX
Path compression
PPTX
Genetic representation
71619109 configuration-management.pdf (1) (1)
80068
242296
Data mining
Parallelizing matrix multiplication
Health care in big data analytics
Ajax
Role of human interaction
Basic analtyics & advanced analtyics
Soap,Rest&Json
Jdbc ja
Remote method invocation
Graph representation
Presentation2
Depth first search [dfs]
Topological sort
Path compression
Genetic representation

Recently uploaded (20)

PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PDF
IGGE1 Understanding the Self1234567891011
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
advance database management system book.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
PDF
Indian roads congress 037 - 2012 Flexible pavement
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
Trump Administration's workforce development strategy
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PDF
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
PDF
Empowerment Technology for Senior High School Guide
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PPTX
History, Philosophy and sociology of education (1).pptx
PDF
Complications of Minimal Access Surgery at WLH
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
IGGE1 Understanding the Self1234567891011
Final Presentation General Medicine 03-08-2024.pptx
advance database management system book.pdf
Supply Chain Operations Speaking Notes -ICLT Program
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
Indian roads congress 037 - 2012 Flexible pavement
What if we spent less time fighting change, and more time building what’s rig...
Trump Administration's workforce development strategy
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
A systematic review of self-coping strategies used by university students to ...
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Chinmaya Tiranga quiz Grand Finale.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
A powerpoint presentation on the Revised K-10 Science Shaping Paper
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
Empowerment Technology for Senior High School Guide
LDMMIA Reiki Yoga Finals Review Spring Summer
History, Philosophy and sociology of education (1).pptx
Complications of Minimal Access Surgery at WLH

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.