SlideShare uma empresa Scribd logo
1 de 14
JAVA APPLET
Elizabeth Alexander
Hindustan University
Applet
● Applets are small Java applications that can be accessed on an Internet server,
transported over Internet, and can be automatically installed and run as a part of a
web document.
● Applet is a special type of program that is embedded in the webpage to generate
the dynamic content.
● It runs inside the browser and works at client side.
● An applet can be a fully functional Java application
● After a user receives an applet, the applet can produce a graphical user interface.
● It has limited access to resources so that it can run complex computations without
introducing the risk of viruses or breaching data integrity.
Applet Cont...
Advantage of Applet
● It works at client side so less response time.
● Secured
● It can be executed by browsers running under many platforms, including Linux,
Windows, Mac Os etc.
● It takes very less response time as it works on the client side.
● It can be run on any browser which has JVM running in it.
Drawback of Applet
● Plugin is required at client browser to execute applet.
Applet Cont...
● Applets are used to make the web site more dynamic and entertaining.
Some important points :
1. All applets are sub-classes of java.applet.Applet class.
2. Applets are not stand-alone programs. Instead, they run within either a web
browser or an applet viewer. JDK provides a standard applet viewer tool called
applet viewer.
3. In general, execution of an applet does not begin at main() method.An applet
class will not define main().
4. Output of an applet window is not performed by System.out.println(). 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.
Applet Architecture
Hierarchy of Applet
● Applet class extends Panel. Panel class extends Container which is the subclass
of Component.
Applet Life Cycle
Applet Life Cycle Cont...
● When an applet begins, the following methods are called, in this sequence:
1. init( )
2. start( )
3. paint( )
● When an applet is terminated, the following sequence of method calls takes place:
1. stop( )
2. destroy( )
Applet Life Cycle Cont...
1.public void init( ) : The init( ) method is the first method to be called.
● This is where you should initialize variables. This method is called only once
during the run time of your applet.
2. public void start( ) : The start( ) method is called after init( ).
● It is also called to restart an applet after it has been stopped.
● Note that init( ) is called once i.e. when the first time an applet is loaded
whereas start( ) is called each time an applet’s HTML document is displayed
onscreen.
● So, if a user leaves a web page and comes back, the applet resumes
execution at start( ).
Applet Life Cycle Cont...
3. public void paint( ) : java.awt.Component class provides 1 life cycle method of
Applet.
● is used to paint the Applet.
● It provides Graphics class object that can be used for drawing oval, rectangle, arc
etc.
● paint( ) is also called when the applet begins execution. Whatever the cause,
whenever the applet must redraw its output, paint( ) is called.
Applet Life Cycle Cont...
4. public void stop( ) : The stop( ) method is called when a web browser leaves the
HTML document containing the applet—when it goes to another page
● When stop( ) is called, the applet is probably running.
● You should use stop( ) to suspend threads that don’t need to run when the applet
is not visible.
5. public void destroy( ) : The destroy( ) method is called when the environment
determines that our applet needs to be removed completely from memory.
● At this point, we should free up any resources the applet may be using.
● The stop( ) method is always called before destroy( ).
The HTML APPLET Tag
● The HTML <applet> tag specifies an applet.
● It is used for embedding a Java applet within an HTML document.
● It is not supported in HTML5.
Passing Parameters to Applets
● Java applet has the feature of retrieving the parameter values passed from the
html page.
● So, you can pass the parameters from your html page to the applet embedded in
your page.
● The param tag(<param name="" value=""></param>) is used to pass the
parameters to an applet.
● The applet has to call the getParameter() method supplied by the
java.applet.Applet parent class.
Passing Parameters to Applets Cont...
Here are three methods commonly used by applets:
● String getParameter(String name)-Returns the value for the specified parameter
string
● URL getCodeBase()-Returns the URL of the applet
● URL getDocumentBase()-Returns the URL of the document containing the applet
Using the Status Window
● In addition to displaying information in its window, an applet can also output a
message to the status window of the browser or applet viewer on which it is
running.
● To do so, call showStatus( ) with the string that you want displayed.
Using the Status Window
● The status window is a good place to give the user feedback about what is
occurring in the applet, suggest options, or possibly report some types of errors.
● The status window also makes an excellent debugging aid, because it gives you
an easy way to output information about your applet.

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

C++ Files and Streams
C++ Files and Streams C++ Files and Streams
C++ Files and Streams
 
Network programming in java - PPT
Network programming in java - PPTNetwork programming in java - PPT
Network programming in java - PPT
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
 
Java Tokens
Java  TokensJava  Tokens
Java Tokens
 
Enumeration in Java Explained | Java Tutorial | Edureka
Enumeration in Java Explained | Java Tutorial | EdurekaEnumeration in Java Explained | Java Tutorial | Edureka
Enumeration in Java Explained | Java Tutorial | Edureka
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Exception handling
Exception handlingException handling
Exception handling
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Html and Xhtml
Html and XhtmlHtml and Xhtml
Html and Xhtml
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
Java Streams
Java StreamsJava Streams
Java Streams
 
Java applets
Java appletsJava applets
Java applets
 
OOP java
OOP javaOOP java
OOP java
 
Exception handling
Exception handlingException handling
Exception handling
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
 
Java I/O
Java I/OJava I/O
Java I/O
 

Semelhante a Java applet (20)

Appletjava
AppletjavaAppletjava
Appletjava
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
 
Advanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.pptAdvanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.ppt
 
Java applet basics
Java applet basicsJava applet basics
Java applet basics
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
 
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
 
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
 
Java Applets
Java AppletsJava Applets
Java Applets
 
Lecture1 oopj
Lecture1 oopjLecture1 oopj
Lecture1 oopj
 
Applet
AppletApplet
Applet
 
Basic of Applet
Basic of AppletBasic of Applet
Basic of Applet
 
27 applet programming
27  applet programming27  applet programming
27 applet programming
 
Applet
AppletApplet
Applet
 
Applet
AppletApplet
Applet
 
Applet in java
Applet in javaApplet in java
Applet in java
 
Oops
OopsOops
Oops
 
Applet (1)
Applet (1)Applet (1)
Applet (1)
 
applet.pptx
applet.pptxapplet.pptx
applet.pptx
 
Unit 7 Java
Unit 7 JavaUnit 7 Java
Unit 7 Java
 

Mais de Elizabeth alexander (11)

Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
 
Io streams
Io streamsIo streams
Io streams
 
Multithreading programming in java
Multithreading programming in javaMultithreading programming in java
Multithreading programming in java
 
Exception handling in java
Exception handling  in javaException handling  in java
Exception handling in java
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Java interfaces
Java   interfacesJava   interfaces
Java interfaces
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
 
Inheritance in Java
Inheritance in JavaInheritance in Java
Inheritance in Java
 
Object oriented programming in java
Object oriented programming in javaObject oriented programming in java
Object oriented programming in java
 
Quantitative Aptitude- Number System
Quantitative Aptitude- Number SystemQuantitative Aptitude- Number System
Quantitative Aptitude- Number System
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 

Último

The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spaintimesproduction05
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdfSuman Jyoti
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLManishPatel169454
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Christo Ananth
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 

Último (20)

The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 

Java applet

  • 2. Applet ● Applets are small Java applications that can be accessed on an Internet server, transported over Internet, and can be automatically installed and run as a part of a web document. ● Applet is a special type of program that is embedded in the webpage to generate the dynamic content. ● It runs inside the browser and works at client side. ● An applet can be a fully functional Java application ● After a user receives an applet, the applet can produce a graphical user interface. ● It has limited access to resources so that it can run complex computations without introducing the risk of viruses or breaching data integrity.
  • 3. Applet Cont... Advantage of Applet ● It works at client side so less response time. ● Secured ● It can be executed by browsers running under many platforms, including Linux, Windows, Mac Os etc. ● It takes very less response time as it works on the client side. ● It can be run on any browser which has JVM running in it. Drawback of Applet ● Plugin is required at client browser to execute applet.
  • 4. Applet Cont... ● Applets are used to make the web site more dynamic and entertaining. Some important points : 1. All applets are sub-classes of java.applet.Applet class. 2. Applets are not stand-alone programs. Instead, they run within either a web browser or an applet viewer. JDK provides a standard applet viewer tool called applet viewer. 3. In general, execution of an applet does not begin at main() method.An applet class will not define main(). 4. Output of an applet window is not performed by System.out.println(). 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. Hierarchy of Applet ● Applet class extends Panel. Panel class extends Container which is the subclass of Component.
  • 8. Applet Life Cycle Cont... ● When an applet begins, the following methods are called, in this sequence: 1. init( ) 2. start( ) 3. paint( ) ● When an applet is terminated, the following sequence of method calls takes place: 1. stop( ) 2. destroy( )
  • 9. Applet Life Cycle Cont... 1.public void init( ) : The init( ) method is the first method to be called. ● This is where you should initialize variables. This method is called only once during the run time of your applet. 2. public void start( ) : The start( ) method is called after init( ). ● It is also called to restart an applet after it has been stopped. ● Note that init( ) is called once i.e. when the first time an applet is loaded whereas start( ) is called each time an applet’s HTML document is displayed onscreen. ● So, if a user leaves a web page and comes back, the applet resumes execution at start( ).
  • 10. Applet Life Cycle Cont... 3. public void paint( ) : java.awt.Component class provides 1 life cycle method of Applet. ● is used to paint the Applet. ● It provides Graphics class object that can be used for drawing oval, rectangle, arc etc. ● paint( ) is also called when the applet begins execution. Whatever the cause, whenever the applet must redraw its output, paint( ) is called.
  • 11. Applet Life Cycle Cont... 4. public void stop( ) : The stop( ) method is called when a web browser leaves the HTML document containing the applet—when it goes to another page ● When stop( ) is called, the applet is probably running. ● You should use stop( ) to suspend threads that don’t need to run when the applet is not visible. 5. public void destroy( ) : The destroy( ) method is called when the environment determines that our applet needs to be removed completely from memory. ● At this point, we should free up any resources the applet may be using. ● The stop( ) method is always called before destroy( ).
  • 12. The HTML APPLET Tag ● The HTML <applet> tag specifies an applet. ● It is used for embedding a Java applet within an HTML document. ● It is not supported in HTML5. Passing Parameters to Applets ● Java applet has the feature of retrieving the parameter values passed from the html page. ● So, you can pass the parameters from your html page to the applet embedded in your page. ● The param tag(<param name="" value=""></param>) is used to pass the parameters to an applet. ● The applet has to call the getParameter() method supplied by the java.applet.Applet parent class.
  • 13. Passing Parameters to Applets Cont... Here are three methods commonly used by applets: ● String getParameter(String name)-Returns the value for the specified parameter string ● URL getCodeBase()-Returns the URL of the applet ● URL getDocumentBase()-Returns the URL of the document containing the applet Using the Status Window ● In addition to displaying information in its window, an applet can also output a message to the status window of the browser or applet viewer on which it is running. ● To do so, call showStatus( ) with the string that you want displayed.
  • 14. Using the Status Window ● The status window is a good place to give the user feedback about what is occurring in the applet, suggest options, or possibly report some types of errors. ● The status window also makes an excellent debugging aid, because it gives you an easy way to output information about your applet.