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
Ad

More Related Content

What's hot (20)

Java applets
Java appletsJava applets
Java applets
Srinath Dhayalamoorthy
 
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 applets
java appletsjava applets
java applets
Waheed Warraich
 
27 applet programming
27  applet programming27  applet programming
27 applet programming
Ravindra Rathore
 
Java applets
Java appletsJava applets
Java applets
Khan Mac-arther
 
Basics of applets.53
Basics of applets.53Basics of applets.53
Basics of applets.53
myrajendra
 
Java Applet
Java AppletJava Applet
Java Applet
Shree M.L.Kakadiya MCA mahila college, Amreli
 
Appl clas nd architect.56
Appl clas nd architect.56Appl clas nd architect.56
Appl clas nd architect.56
myrajendra
 
Java introduction
Java introductionJava introduction
Java introduction
logeswarisaravanan
 
Java Programming- Introduction to Java Applet Programs
Java Programming- Introduction to Java Applet ProgramsJava Programming- Introduction to Java Applet Programs
Java Programming- Introduction to Java Applet Programs
Trinity Dwarka
 
Applets
AppletsApplets
Applets
radon2569
 
Applet programming in java
Applet programming in javaApplet programming in java
Applet programming in java
Vidya Bharti
 
Java applet
Java appletJava applet
Java applet
Arati Gadgil
 
Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...
Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...
Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...
seleniumconf
 
Java applets
Java appletsJava applets
Java applets
lopjuan
 
Applet (1)
Applet (1)Applet (1)
Applet (1)
DEEPIKA T
 
Java applet-basics
Java applet-basicsJava applet-basics
Java applet-basics
kanchanmahajan23
 
Lotusphere 2011 Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...
Lotusphere 2011  Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...Lotusphere 2011  Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...
Lotusphere 2011 Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...
Ryan Baxter
 
Java applet-basics
Java applet-basicsJava applet-basics
Java applet-basics
kanchanmahajan23
 
ITFT- Applet in java
ITFT- Applet in javaITFT- Applet in java
ITFT- Applet in java
Atul Sehdev
 
Basics of applets.53
Basics of applets.53Basics of applets.53
Basics of applets.53
myrajendra
 
Appl clas nd architect.56
Appl clas nd architect.56Appl clas nd architect.56
Appl clas nd architect.56
myrajendra
 
Java Programming- Introduction to Java Applet Programs
Java Programming- Introduction to Java Applet ProgramsJava Programming- Introduction to Java Applet Programs
Java Programming- Introduction to Java Applet Programs
Trinity Dwarka
 
Applet programming in java
Applet programming in javaApplet programming in java
Applet programming in java
Vidya Bharti
 
Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...
Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...
Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...
seleniumconf
 
Java applets
Java appletsJava applets
Java applets
lopjuan
 
Lotusphere 2011 Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...
Lotusphere 2011  Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...Lotusphere 2011  Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...
Lotusphere 2011 Jmp103 - Jumpstart Your "Jedi Plug-in Development Skills" wi...
Ryan Baxter
 

Similar to Jsp applet (20)

applet.pptx
applet.pptxapplet.pptx
applet.pptx
SachinBhosale73
 
MSBTE Computer Engineering Java applet.pptx
MSBTE Computer Engineering Java applet.pptxMSBTE Computer Engineering Java applet.pptx
MSBTE Computer Engineering Java applet.pptx
kunalgaikwad1705
 
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
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
sanchi Sharma
 
Java programming basics notes for beginners(java programming tutorials)
Java programming basics notes for beginners(java programming tutorials)Java programming basics notes for beginners(java programming tutorials)
Java programming basics notes for beginners(java programming tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
Nexus
 
Advanced programming chapter 2 - Java Applet.pdf
Advanced programming chapter 2 - Java Applet.pdfAdvanced programming chapter 2 - Java Applet.pdf
Advanced programming chapter 2 - Java Applet.pdf
fikadumeuedu
 
Advanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.pptAdvanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.ppt
miki304759
 
JAVA APPLET BASICS
JAVA APPLET BASICSJAVA APPLET BASICS
JAVA APPLET BASICS
Shanid Malayil
 
Applet.pptx
Applet.pptxApplet.pptx
Applet.pptx
LakachewYezihalem
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
Gomathi Gomu
 
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
 
Unit 7 Java
Unit 7 JavaUnit 7 Java
Unit 7 Java
arnold 7490
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
Gary Mendonca
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
RamaPrabha24
 
Applet in java
Applet in javaApplet in java
Applet in java
Jancypriya M
 
Java Applets
Java AppletsJava Applets
Java Applets
Dr. Jasmine Beulah Gnanadurai
 
Java applet
Java appletJava applet
Java applet
Elizabeth alexander
 
Java Apple dndkorksnsbsjdkkdjejdjrdndjdj
Java Apple dndkorksnsbsjdkkdjejdjrdndjdjJava Apple dndkorksnsbsjdkkdjejdjrdndjdj
Java Apple dndkorksnsbsjdkkdjejdjrdndjdj
midhunmsd143
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
mcanotes
 
MSBTE Computer Engineering Java applet.pptx
MSBTE Computer Engineering Java applet.pptxMSBTE Computer Engineering Java applet.pptx
MSBTE Computer Engineering Java applet.pptx
kunalgaikwad1705
 
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
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
Nexus
 
Advanced programming chapter 2 - Java Applet.pdf
Advanced programming chapter 2 - Java Applet.pdfAdvanced programming chapter 2 - Java Applet.pdf
Advanced programming chapter 2 - Java Applet.pdf
fikadumeuedu
 
Advanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.pptAdvanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.ppt
miki304759
 
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
 
Java Apple dndkorksnsbsjdkkdjejdjrdndjdj
Java Apple dndkorksnsbsjdkkdjejdjrdndjdjJava Apple dndkorksnsbsjdkkdjejdjrdndjdj
Java Apple dndkorksnsbsjdkkdjejdjrdndjdj
midhunmsd143
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
mcanotes
 
Ad

More from Sanoj Kumar (14)

Internet of things
Internet of thingsInternet of things
Internet of things
Sanoj Kumar
 
Corba
CorbaCorba
Corba
Sanoj Kumar
 
Dns
DnsDns
Dns
Sanoj Kumar
 
Big data and Internet
Big data and InternetBig data and Internet
Big data and Internet
Sanoj Kumar
 
Ajax
AjaxAjax
Ajax
Sanoj Kumar
 
A New Security Model For Distributed System
A New Security Model For Distributed SystemA New Security Model For Distributed System
A New Security Model For Distributed System
Sanoj Kumar
 
A New Form of Dos attack in Cloud
A New Form of Dos attack in CloudA New Form of Dos attack in Cloud
A New Form of Dos attack in Cloud
Sanoj Kumar
 
Biometrics
BiometricsBiometrics
Biometrics
Sanoj Kumar
 
IPC SOCKET
IPC SOCKETIPC SOCKET
IPC SOCKET
Sanoj Kumar
 
Inverted page tables basic
Inverted page tables basicInverted page tables basic
Inverted page tables basic
Sanoj Kumar
 
Hardware virtualization basic
Hardware virtualization basicHardware virtualization basic
Hardware virtualization basic
Sanoj Kumar
 
Dos attack basic
Dos attack basicDos attack basic
Dos attack basic
Sanoj Kumar
 
Steganography basic
Steganography basicSteganography basic
Steganography basic
Sanoj Kumar
 
Digital signatures
Digital signaturesDigital signatures
Digital signatures
Sanoj Kumar
 
Internet of things
Internet of thingsInternet of things
Internet of things
Sanoj Kumar
 
Big data and Internet
Big data and InternetBig data and Internet
Big data and Internet
Sanoj Kumar
 
A New Security Model For Distributed System
A New Security Model For Distributed SystemA New Security Model For Distributed System
A New Security Model For Distributed System
Sanoj Kumar
 
A New Form of Dos attack in Cloud
A New Form of Dos attack in CloudA New Form of Dos attack in Cloud
A New Form of Dos attack in Cloud
Sanoj Kumar
 
Inverted page tables basic
Inverted page tables basicInverted page tables basic
Inverted page tables basic
Sanoj Kumar
 
Hardware virtualization basic
Hardware virtualization basicHardware virtualization basic
Hardware virtualization basic
Sanoj Kumar
 
Dos attack basic
Dos attack basicDos attack basic
Dos attack basic
Sanoj Kumar
 
Steganography basic
Steganography basicSteganography basic
Steganography basic
Sanoj Kumar
 
Digital signatures
Digital signaturesDigital signatures
Digital signatures
Sanoj Kumar
 
Ad

Recently uploaded (20)

Personal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.pptPersonal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.ppt
ganjangbegu579
 
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
PawachMetharattanara
 
Artificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptxArtificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptx
rakshanatarajan005
 
Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...
Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...
Prediction of Flexural Strength of Concrete Produced by Using Pozzolanic Mate...
Journal of Soft Computing in Civil Engineering
 
Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control Monthly May 2025Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control
 
Lecture - 7 Canals of the topic of the civil engineering
Lecture - 7  Canals of the topic of the civil engineeringLecture - 7  Canals of the topic of the civil engineering
Lecture - 7 Canals of the topic of the civil engineering
MJawadkhan1
 
JRR Tolkien’s Lord of the Rings: Was It Influenced by Nordic Mythology, Homer...
JRR Tolkien’s Lord of the Rings: Was It Influenced by Nordic Mythology, Homer...JRR Tolkien’s Lord of the Rings: Was It Influenced by Nordic Mythology, Homer...
JRR Tolkien’s Lord of the Rings: Was It Influenced by Nordic Mythology, Homer...
Reflections on Morality, Philosophy, and History
 
Applications of Centroid in Structural Engineering
Applications of Centroid in Structural EngineeringApplications of Centroid in Structural Engineering
Applications of Centroid in Structural Engineering
suvrojyotihalder2006
 
Working with USDOT UTCs: From Conception to Implementation
Working with USDOT UTCs: From Conception to ImplementationWorking with USDOT UTCs: From Conception to Implementation
Working with USDOT UTCs: From Conception to Implementation
Alabama Transportation Assistance Program
 
2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt
rakshaiya16
 
Construction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil EngineeringConstruction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil Engineering
Lavish Kashyap
 
Control Methods of Noise Pollutions.pptx
Control Methods of Noise Pollutions.pptxControl Methods of Noise Pollutions.pptx
Control Methods of Noise Pollutions.pptx
vvsasane
 
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Journal of Soft Computing in Civil Engineering
 
Slide share PPT of NOx control technologies.pptx
Slide share PPT of  NOx control technologies.pptxSlide share PPT of  NOx control technologies.pptx
Slide share PPT of NOx control technologies.pptx
vvsasane
 
Nanometer Metal-Organic-Framework Literature Comparison
Nanometer Metal-Organic-Framework  Literature ComparisonNanometer Metal-Organic-Framework  Literature Comparison
Nanometer Metal-Organic-Framework Literature Comparison
Chris Harding
 
DED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedungDED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedung
nabilarizqifadhilah1
 
Agents chapter of Artificial intelligence
Agents chapter of Artificial intelligenceAgents chapter of Artificial intelligence
Agents chapter of Artificial intelligence
DebdeepMukherjee9
 
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdfSmart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
PawachMetharattanara
 
SICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introductionSICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introduction
fabienklr
 
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjjseninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
AjijahamadKhaji
 
Personal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.pptPersonal Protective Efsgfgsffquipment.ppt
Personal Protective Efsgfgsffquipment.ppt
ganjangbegu579
 
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
PawachMetharattanara
 
Artificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptxArtificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptx
rakshanatarajan005
 
Lecture - 7 Canals of the topic of the civil engineering
Lecture - 7  Canals of the topic of the civil engineeringLecture - 7  Canals of the topic of the civil engineering
Lecture - 7 Canals of the topic of the civil engineering
MJawadkhan1
 
Applications of Centroid in Structural Engineering
Applications of Centroid in Structural EngineeringApplications of Centroid in Structural Engineering
Applications of Centroid in Structural Engineering
suvrojyotihalder2006
 
2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt
rakshaiya16
 
Construction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil EngineeringConstruction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil Engineering
Lavish Kashyap
 
Control Methods of Noise Pollutions.pptx
Control Methods of Noise Pollutions.pptxControl Methods of Noise Pollutions.pptx
Control Methods of Noise Pollutions.pptx
vvsasane
 
Slide share PPT of NOx control technologies.pptx
Slide share PPT of  NOx control technologies.pptxSlide share PPT of  NOx control technologies.pptx
Slide share PPT of NOx control technologies.pptx
vvsasane
 
Nanometer Metal-Organic-Framework Literature Comparison
Nanometer Metal-Organic-Framework  Literature ComparisonNanometer Metal-Organic-Framework  Literature Comparison
Nanometer Metal-Organic-Framework Literature Comparison
Chris Harding
 
DED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedungDED KOMINFO detail engginering design gedung
DED KOMINFO detail engginering design gedung
nabilarizqifadhilah1
 
Agents chapter of Artificial intelligence
Agents chapter of Artificial intelligenceAgents chapter of Artificial intelligence
Agents chapter of Artificial intelligence
DebdeepMukherjee9
 
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdfSmart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
PawachMetharattanara
 
SICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introductionSICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introduction
fabienklr
 
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjjseninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
seninarppt.pptx1bhjiikjhggghjykoirgjuyhhhjj
AjijahamadKhaji
 

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.
  翻译: