SlideShare a Scribd company logo
ppt15
1
Topics for today
 Java Applets
2
What is an Applet?
• In the computing world, Applet is a small application program
that performs one specific task sometimes running within the
context of a larger program as a plugin (extending capabilities
of a larger program)
• They are not full featured application programs
• Small in size and performs only a small set of tasks
• Eg. Accessories (applications in MS Windows), Web Based
Applets like Quick Time Movies, Flash Movies
Features of Applet
• Applets execute only on the "client" platform environment of
a system, as contrasted from "servlet". As such, an applet
provides functionality or performance beyond the default
capabilities of its container (the browser).
• The container (class) restricts applets' capabilities.
• Applets are written in a language different from the scripting
or HTML language which invokes it. The applet is written in a
compiled language, while the scripting language of the
container is an interpreted language, hence the greater
performance or functionality of the applet. Unlike a
"subroutine", a complete web component can be
implemented as an applet.
What is Java Applet?
• An Java applet is a program written in the Java programming
language that can be included in an HTML page, much in the
same way an image is included in a page and can run in Java
Virtual Machine or Sun’s Applet Viewer
• Java applets were introduced in the first version of the Java
language in 1995
• They can also be written in other form of languages
• Java Applets do not have main() method as an entry point but
instead, have several methods to control specific aspects
of applet execution.
Example 1
import java.applet.Applet;
import java.awt.Graphics;
public class HelloWorld extends Applet
{
public void init()
{
// empty for now
}
public void paint(Graphics g)
{ g.drawString("Hello World", 20, 20);
}
}
Steps for writing Applets
• Type in Text Editor and save as Helloworld.java
• Compile as javac Helloworld.java
• Create a HTML file and save it as hello.html and put the below text
<html>
<body>
<applet code=HelloWorld width=30 height=200>
</applet>
</body>
</html>
• Open the HTML file
Understanding what happened
import java.applet.Applet; //importing Applet class
import java.awt.Graphics; //importing Graphic class from AWT from file
java.awt.Graphics.html installed during JDK
installation from file path
X:jdk1.1.7docsapijava.awt.Graphics.html
public class HelloWorld extends Applet //Extends Applet class
{
// init method is used to initialise any variables, objects , necessary method
public void init() {
// empty for now
}
public void paint(Graphics g) //Instance of Graphic class
{ created as g calling draw method
g.drawString("Hello World", 20, 20);
}
}
Applet class
- Provides the platform to design the
appearance and manage the behavior of applet
- Provides GUI component called Panel and many
methods
- Provides init, start, stop, destroy, and paint
methods which has no functionality means they
are empty functions
- Extended class overrides on this methods
- Also provides methods that can be inherited
Example 2
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Color;
public class SimpleApplet extends Applet
{
String text = "I'm a simple applet";
public void init()
{
text = "I'm a simple applet";
setBackground(Color.cyan);
}
public void start()
{ System.out.println("starting...");
}
public void stop()
{
System.out.println("stopping...");
}
public void destroy()
{
System.out.println("preparing to unload...");
}
public void paint(Graphics g)
{
System.out.println("Paint");
g.setColor(Color.blue);
g.drawRect(0, 0, getSize().width -1, getSize().height -1);
g.setColor(Color.red); g.drawString(text, 15, 25);
}
}
Behavior or Life Cycle of Applet
An applet is controlled by the software that runs it.
• The init Method: The init method is called when the applet is first created and
loaded by the underlying software. This method performs one-time operations the
applet needs for its operation such as creating the user interface or setting the
font.
• The start Method: The start method is called when the applet is visited such as
when the end user goes to a web page with an applet on it. The example prints a
string to the console to tell you the applet is starting. In a more complex applet,
the start method would do things required at the start of the applet such as begin
animation or play sounds.
After the start method executes, the event thread calls the paint method to draw
to the applet's Panel. A thread is a single sequential flow of control within the
applet, and every applet can run in multiple threads.
• Stop Method: The stop method stops the applet when the applet is no longer on
the screen such as when the end user goes to another web page. Like stop
animation or sounds.
• Destroy Methods: The destroy method is called when the browser exits.
Extending Class
Packages
• Import statement used in Java applet program
calls the class which are stored in different
packages
• eg. java.applet is a Package and Applet is a
ready made precompiled JavaAPI class for
import java.applet.Applet statement
• eg. java.lang.* calls all the packages within
that package
Advantages of using Java Applet
• Provides web applications with interactive features that cannot be
provided by HTML
• Can be executed by most browsers in any platforms due to Java
bytecodes independence
• The same applet can work on "all" installed versions of Java at the
same time, rather than just the latest plug-in version only
• It can move the work from the server to the client, making a web
solution more scalable with the number of users/clients
Technique to refer with HTML
Using <APPLET> tag
Disadvantages of Java Applet
• It requires the Java plug-in and for organizations that only
allow software installed by the administrators by contacting
the administrator to request installation of the Java plug-in.
• Some applets require a specific JRE or newer JRE and if
required than available on the system the user running it the
first time will need to wait for the large JRE download to
complete.
• Java automatic installation or update may fail if a proxy server
is used to access the web. This makes applets with specific
requirements impossible to run unless Java is manually
updated. The Java automatic updater that is part of a Java
installation also may be complex to configure if it must work
through a proxy.
Jsp applet

More Related Content

What's hot (20)

PPS
Java applets
Srinath Dhayalamoorthy
 
PDF
ITFT- Applet in java
Atul Sehdev
 
PPTX
Applet progming
VIKRANTHMALLIKARJUN
 
PPT
java applets
Waheed Warraich
 
PDF
27 applet programming
Ravindra Rathore
 
PPT
Java applets
Khan Mac-arther
 
PPT
Basics of applets.53
myrajendra
 
PPT
Appl clas nd architect.56
myrajendra
 
PPT
Java introduction
logeswarisaravanan
 
PPTX
Java Programming- Introduction to Java Applet Programs
Trinity Dwarka
 
ODP
Applets
radon2569
 
PPTX
Applet programming in java
Vidya Bharti
 
PPT
Java applet
Arati Gadgil
 
PPTX
Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...
seleniumconf
 
PPT
Java applets
lopjuan
 
PPTX
Applet (1)
DEEPIKA T
 
PDF
Java applet-basics
kanchanmahajan23
 
ODP
Lotusphere 2011 Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...
Ryan Baxter
 
DOCX
Java applet-basics
kanchanmahajan23
 
ITFT- Applet in java
Atul Sehdev
 
Applet progming
VIKRANTHMALLIKARJUN
 
java applets
Waheed Warraich
 
27 applet programming
Ravindra Rathore
 
Java applets
Khan Mac-arther
 
Basics of applets.53
myrajendra
 
Appl clas nd architect.56
myrajendra
 
Java introduction
logeswarisaravanan
 
Java Programming- Introduction to Java Applet Programs
Trinity Dwarka
 
Applets
radon2569
 
Applet programming in java
Vidya Bharti
 
Java applet
Arati Gadgil
 
Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...
seleniumconf
 
Java applets
lopjuan
 
Applet (1)
DEEPIKA T
 
Java applet-basics
kanchanmahajan23
 
Lotusphere 2011 Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...
Ryan Baxter
 
Java applet-basics
kanchanmahajan23
 

Similar to Jsp applet (20)

PPTX
applet.pptx
SachinBhosale73
 
PPTX
MSBTE Computer Engineering Java applet.pptx
kunalgaikwad1705
 
PDF
Class notes(week 10) on applet programming
Kuntal Bhowmick
 
PDF
Java programming basics notes for beginners(java programming tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
PDF
Java basics notes
sanchi Sharma
 
PDF
Java basics notes
Nexus
 
PDF
Advanced programming chapter 2 - Java Applet.pdf
fikadumeuedu
 
PPT
Advanced Programming, Java Programming, Applets.ppt
miki304759
 
PPT
JAVA APPLET BASICS
Shanid Malayil
 
PPTX
Applet.pptx
LakachewYezihalem
 
PDF
Java basics notes
Gomathi Gomu
 
DOCX
Class notes(week 10) on applet programming
Kuntal Bhowmick
 
PPT
Unit 7 Java
arnold 7490
 
PPTX
Applets in Java
Gary Mendonca
 
PPTX
Applets in Java
RamaPrabha24
 
PDF
Applet in java
Jancypriya M
 
PPTX
Java applet
Elizabeth alexander
 
PPTX
Java Apple dndkorksnsbsjdkkdjejdjrdndjdj
midhunmsd143
 
PPT
Applet and graphics programming
mcanotes
 
applet.pptx
SachinBhosale73
 
MSBTE Computer Engineering Java applet.pptx
kunalgaikwad1705
 
Class notes(week 10) on applet programming
Kuntal Bhowmick
 
Java programming basics notes for beginners(java programming tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
Java basics notes
sanchi Sharma
 
Java basics notes
Nexus
 
Advanced programming chapter 2 - Java Applet.pdf
fikadumeuedu
 
Advanced Programming, Java Programming, Applets.ppt
miki304759
 
JAVA APPLET BASICS
Shanid Malayil
 
Applet.pptx
LakachewYezihalem
 
Java basics notes
Gomathi Gomu
 
Class notes(week 10) on applet programming
Kuntal Bhowmick
 
Unit 7 Java
arnold 7490
 
Applets in Java
Gary Mendonca
 
Applets in Java
RamaPrabha24
 
Applet in java
Jancypriya M
 
Java applet
Elizabeth alexander
 
Java Apple dndkorksnsbsjdkkdjejdjrdndjdj
midhunmsd143
 
Applet and graphics programming
mcanotes
 
Ad

More from Sanoj Kumar (14)

PPTX
Internet of things
Sanoj Kumar
 
PPT
Corba
Sanoj Kumar
 
PPT
Dns
Sanoj Kumar
 
PPT
Big data and Internet
Sanoj Kumar
 
PPT
Ajax
Sanoj Kumar
 
PPTX
A New Security Model For Distributed System
Sanoj Kumar
 
PPTX
A New Form of Dos attack in Cloud
Sanoj Kumar
 
PPTX
Biometrics
Sanoj Kumar
 
PPTX
IPC SOCKET
Sanoj Kumar
 
PPTX
Inverted page tables basic
Sanoj Kumar
 
PPTX
Hardware virtualization basic
Sanoj Kumar
 
PPTX
Dos attack basic
Sanoj Kumar
 
PPTX
Steganography basic
Sanoj Kumar
 
PPTX
Digital signatures
Sanoj Kumar
 
Internet of things
Sanoj Kumar
 
Big data and Internet
Sanoj Kumar
 
A New Security Model For Distributed System
Sanoj Kumar
 
A New Form of Dos attack in Cloud
Sanoj Kumar
 
Biometrics
Sanoj Kumar
 
IPC SOCKET
Sanoj Kumar
 
Inverted page tables basic
Sanoj Kumar
 
Hardware virtualization basic
Sanoj Kumar
 
Dos attack basic
Sanoj Kumar
 
Steganography basic
Sanoj Kumar
 
Digital signatures
Sanoj Kumar
 
Ad

Recently uploaded (20)

PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PDF
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
PPTX
Snet+Pro+Service+Software_SNET+Pro+2+Instructions.pptx
jenilsatikuvar1
 
PPTX
Element 7. CHEMICAL AND BIOLOGICAL AGENT.pptx
merrandomohandas
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PPTX
Green Building & Energy Conservation ppt
Sagar Sarangi
 
PPTX
UNIT DAA PPT cover all topics 2021 regulation
archu26
 
PPTX
GitOps_Repo_Structure for begeinner(Scaffolindg)
DanialHabibi2
 
PPTX
MPMC_Module-2 xxxxxxxxxxxxxxxxxxxxx.pptx
ShivanshVaidya5
 
PDF
Water Design_Manual_2005. KENYA FOR WASTER SUPPLY AND SEWERAGE
DancanNgutuku
 
PPTX
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
PPTX
Introduction to Design of Machine Elements
PradeepKumarS27
 
PPTX
Server Side Web Development Unit 1 of Nodejs.pptx
sneha852132
 
PDF
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
PPTX
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
PDF
Ethics and Trustworthy AI in Healthcare – Governing Sensitive Data, Profiling...
AlqualsaDIResearchGr
 
PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
PDF
6th International Conference on Machine Learning Techniques and Data Science ...
ijistjournal
 
PDF
monopile foundation seminar topic for civil engineering students
Ahina5
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
Snet+Pro+Service+Software_SNET+Pro+2+Instructions.pptx
jenilsatikuvar1
 
Element 7. CHEMICAL AND BIOLOGICAL AGENT.pptx
merrandomohandas
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
Green Building & Energy Conservation ppt
Sagar Sarangi
 
UNIT DAA PPT cover all topics 2021 regulation
archu26
 
GitOps_Repo_Structure for begeinner(Scaffolindg)
DanialHabibi2
 
MPMC_Module-2 xxxxxxxxxxxxxxxxxxxxx.pptx
ShivanshVaidya5
 
Water Design_Manual_2005. KENYA FOR WASTER SUPPLY AND SEWERAGE
DancanNgutuku
 
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
Introduction to Design of Machine Elements
PradeepKumarS27
 
Server Side Web Development Unit 1 of Nodejs.pptx
sneha852132
 
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
Ethics and Trustworthy AI in Healthcare – Governing Sensitive Data, Profiling...
AlqualsaDIResearchGr
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
6th International Conference on Machine Learning Techniques and Data Science ...
ijistjournal
 
monopile foundation seminar topic for civil engineering students
Ahina5
 

Jsp applet

  • 2. Topics for today  Java Applets 2
  • 3. What is an Applet? • In the computing world, Applet is a small application program that performs one specific task sometimes running within the context of a larger program as a plugin (extending capabilities of a larger program) • They are not full featured application programs • Small in size and performs only a small set of tasks • Eg. Accessories (applications in MS Windows), Web Based Applets like Quick Time Movies, Flash Movies
  • 4. Features of Applet • Applets execute only on the "client" platform environment of a system, as contrasted from "servlet". As such, an applet provides functionality or performance beyond the default capabilities of its container (the browser). • The container (class) restricts applets' capabilities. • Applets are written in a language different from the scripting or HTML language which invokes it. The applet is written in a compiled language, while the scripting language of the container is an interpreted language, hence the greater performance or functionality of the applet. Unlike a "subroutine", a complete web component can be implemented as an applet.
  • 5. What is Java Applet? • An Java applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a page and can run in Java Virtual Machine or Sun’s Applet Viewer • Java applets were introduced in the first version of the Java language in 1995 • They can also be written in other form of languages • Java Applets do not have main() method as an entry point but instead, have several methods to control specific aspects of applet execution.
  • 6. Example 1 import java.applet.Applet; import java.awt.Graphics; public class HelloWorld extends Applet { public void init() { // empty for now } public void paint(Graphics g) { g.drawString("Hello World", 20, 20); } }
  • 7. Steps for writing Applets • Type in Text Editor and save as Helloworld.java • Compile as javac Helloworld.java • Create a HTML file and save it as hello.html and put the below text <html> <body> <applet code=HelloWorld width=30 height=200> </applet> </body> </html> • Open the HTML file
  • 8. Understanding what happened import java.applet.Applet; //importing Applet class import java.awt.Graphics; //importing Graphic class from AWT from file java.awt.Graphics.html installed during JDK installation from file path X:jdk1.1.7docsapijava.awt.Graphics.html public class HelloWorld extends Applet //Extends Applet class { // init method is used to initialise any variables, objects , necessary method public void init() { // empty for now } public void paint(Graphics g) //Instance of Graphic class { created as g calling draw method g.drawString("Hello World", 20, 20); } }
  • 9. Applet class - Provides the platform to design the appearance and manage the behavior of applet - Provides GUI component called Panel and many methods - Provides init, start, stop, destroy, and paint methods which has no functionality means they are empty functions - Extended class overrides on this methods - Also provides methods that can be inherited
  • 10. Example 2 import java.applet.Applet; import java.awt.Graphics; import java.awt.Color; public class SimpleApplet extends Applet { String text = "I'm a simple applet"; public void init() { text = "I'm a simple applet"; setBackground(Color.cyan); } public void start() { System.out.println("starting..."); } public void stop() { System.out.println("stopping..."); }
  • 11. public void destroy() { System.out.println("preparing to unload..."); } public void paint(Graphics g) { System.out.println("Paint"); g.setColor(Color.blue); g.drawRect(0, 0, getSize().width -1, getSize().height -1); g.setColor(Color.red); g.drawString(text, 15, 25); } }
  • 12. Behavior or Life Cycle of Applet An applet is controlled by the software that runs it. • The init Method: The init method is called when the applet is first created and loaded by the underlying software. This method performs one-time operations the applet needs for its operation such as creating the user interface or setting the font. • The start Method: The start method is called when the applet is visited such as when the end user goes to a web page with an applet on it. The example prints a string to the console to tell you the applet is starting. In a more complex applet, the start method would do things required at the start of the applet such as begin animation or play sounds. After the start method executes, the event thread calls the paint method to draw to the applet's Panel. A thread is a single sequential flow of control within the applet, and every applet can run in multiple threads. • Stop Method: The stop method stops the applet when the applet is no longer on the screen such as when the end user goes to another web page. Like stop animation or sounds. • Destroy Methods: The destroy method is called when the browser exits.
  • 14. Packages • Import statement used in Java applet program calls the class which are stored in different packages • eg. java.applet is a Package and Applet is a ready made precompiled JavaAPI class for import java.applet.Applet statement • eg. java.lang.* calls all the packages within that package
  • 15. Advantages of using Java Applet • Provides web applications with interactive features that cannot be provided by HTML • Can be executed by most browsers in any platforms due to Java bytecodes independence • The same applet can work on "all" installed versions of Java at the same time, rather than just the latest plug-in version only • It can move the work from the server to the client, making a web solution more scalable with the number of users/clients Technique to refer with HTML Using <APPLET> tag
  • 16. Disadvantages of Java Applet • It requires the Java plug-in and for organizations that only allow software installed by the administrators by contacting the administrator to request installation of the Java plug-in. • Some applets require a specific JRE or newer JRE and if required than available on the system the user running it the first time will need to wait for the large JRE download to complete. • Java automatic installation or update may fail if a proxy server is used to access the web. This makes applets with specific requirements impossible to run unless Java is manually updated. The Java automatic updater that is part of a Java installation also may be complex to configure if it must work through a proxy.