SlideShare a Scribd company logo
APPLET
SCION RESEARCH AND DEVELOPMENT
Applet in Java
Applet is a predefined class in java.applet package used to design
distributed application. It is a client side technology. Applets are run on
web browser.
Advantage of Applet
• Applets are supported by most web browsers.
• Applets works on client side so less response time.
• Secured: No access to the local machine and can only access the server it
came from.
• Easy to develop applet, just extends applet class.
• To run applets, it requires the Java plug-in at client side.
• Android, do not run Java applets.
• Some applets require a specific JRE. If it required new JRE then it take
more time to download new JRE.
APPLET IN JAVA
SCION RESEARCH AND DEVELOPMENT
3
Life cycle of applet
init()
start()
stop
destroy
APPLET IN JAVA
SCION RESEARCH AND DEVELOPMENT
4
init(): Which will be executed whenever an applet program start loading, it
contains the logic to initiate the applet properties.
start(): It will be executed whenever the applet program starts running.
stop(): Which will be executed whenever the applet window or browser is
minimized.
destroy(): It will be executed whenever the applet window or browser is
going to be closed (at the time of destroying the applet program
permanently).
APPLET IN JAVA
SCION RESEARCH AND DEVELOPMENT
5
Design applet program
We can design our own applet program by extending applet class in the
user defined class.
Syntax
class className extends Applet
{
......
// override lifecycle methods
......
}
Note: Whenever an applet program is running init() and start() will be
executed one after another, but stop() and destroy() will be executed if the
browser is minimized and closed by the end user, respectively.
Note: Applet program may or may not contain life cycle methods.
APPLET IN JAVA
SCION RESEARCH AND DEVELOPMENT
6
Running of applet programs
Applet program can run in two ways.
• Using html (in the web browser)
• Using appletviewer tool (in applet window)
Running of applet using html
In general no Java program can directly execute on the web browser except
markup language like html, xml etc.
Html support a predefined tag called <applet> to load the applet program
on the browser window.
Syntax
<applet code="udc.class">
height="100px"
width="100px"
</applet>
APPLET IN JAVA
SCION RESEARCH AND DEVELOPMENT
7
APPLET IN JAVA
SCION RESEARCH AND DEVELOPMENT
8
APPLET IN JAVA
SCION RESEARCH AND DEVELOPMENT
9
APPLET IN JAVA
SCION RESEARCH AND DEVELOPMENT
10
APPLET IN JAVA
SCION RESEARCH AND DEVELOPMENT
11
APPLET IN JAVA
SCION RESEARCH AND DEVELOPMENT
12
APPLET IN JAVA
SCION RESEARCH AND DEVELOPMENT
13
APPLET IN JAVA
SCION RESEARCH AND DEVELOPMENT
14
APPLET IN JAVA
SCION RESEARCH AND DEVELOPMENT
15
Example of applet program to run applet using html
Java code, JavaApp.java
import java.applet.*;
import java.awt.*;
public class JavaApp extends Applet {
public void paint(Graphics g) {
Font f=new Font("Arial",Font.BOLD,30);
g.setFont(f);
setForeground(Color.red);
setBackground(Color.white);
g.drawString("Student",200,200);
}
}
Html code, myapplet.html
<html>
<title> AppletEx</Title>
<body>
<applet code="JavaApp.class"
height="70%“ width="80%">
</applet>
</body>
</html>
APPLET IN JAVA
SCION RESEARCH AND DEVELOPMENT
16
If applet code not run on browser then allow blocked contents.
Running of applet using appletviewer
• Some browser does not support <applet> tag so that Sun MicroSystem
was introduced a special tool called appletviewer to run the applet
program.
• In this Scenario Java program should contain <applet> tag in the
commented lines so that appletviewer tools can run the current applet
program.
APPLET IN JAVA
SCION RESEARCH AND DEVELOPMENT
17
Example of Applet
import java.applet.*;
import java.awt.*;
/*<applet code="LifeApp.class" height="500“ ,width="800"> </applet>*/
public class LifeApp extends Applet
{
String s= " ";
public void init()
{
s=s+ " int ";
}
public void start()
{
s=s+ "start ";
APPLET IN JAVA
SCION RESEARCH AND DEVELOPMENT
18
}
public void stop() {
s=s+ "stop "; }
public void destroy() {
s=s+ " destory ";
}
public void paint(Graphics g) {
Font f=new Font("Arial",Font.BOLD,30);
setBackgroundColor(Color."red");
g.setFont(f);
g.drawString(s,200,250);
}
}
APPLET IN JAVA
SCION RESEARCH AND DEVELOPMENT
19
Execution of applet program
javac LifeApp.javaappletviewer LifeApp.java
Note: init() always execute only once at the time of loading applet window
and also it will be executed if the applet is restarted.
Factory Method in Java
A factory method is one whose return type is similar to the class name in
which class is present. The purpose of factory method is to create an object
without using new operator.
APPLET IN JAVA
SCION RESEARCH AND DEVELOPMENT
20
Rules for writing factory method
• The return type of the factory method must be similar to class name in
which class it presents.
• Every factory method in java is static.
• The access specifies of the factory method must be public.
APPLET IN JAVA

More Related Content

Similar to APPLET.pptx

Java basics notes
Java basics notesJava basics notes
Java basics notes
Nexus
 
Java applet basics
Java applet basicsJava applet basics
Java applet basics
Sunil Pandey
 

Similar to APPLET.pptx (20)

Java applet
Java appletJava applet
Java applet
 
Applet
AppletApplet
Applet
 
Java Applets
Java AppletsJava Applets
Java Applets
 
Oops
OopsOops
Oops
 
Java applet-basics
Java applet-basicsJava applet-basics
Java applet-basics
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
 
Appletjava
AppletjavaAppletjava
Appletjava
 
Java Applets
Java AppletsJava Applets
Java Applets
 
Java applet-basics
Java applet-basicsJava applet-basics
Java applet-basics
 
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
 
Jsp applet
Jsp appletJsp applet
Jsp applet
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
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)
 
Unit 7 Java
Unit 7 JavaUnit 7 Java
Unit 7 Java
 
27 applet programming
27  applet programming27  applet programming
27 applet programming
 
PROGRAMMING IN JAVA- unit 4-part I
PROGRAMMING IN JAVA- unit 4-part IPROGRAMMING IN JAVA- unit 4-part I
PROGRAMMING IN JAVA- unit 4-part I
 
Java applet - java
Java applet - javaJava applet - java
Java applet - java
 
Java applet basics
Java applet basicsJava applet basics
Java applet basics
 
Advanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.pptAdvanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.ppt
 

Recently uploaded

Digital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdfDigital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdf
AbrahamGadissa
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
Kamal Acharya
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 

Recently uploaded (20)

Digital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdfDigital Signal Processing Lecture notes n.pdf
Digital Signal Processing Lecture notes n.pdf
 
Top 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering ScientistTop 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering Scientist
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering Workshop
 
Toll tax management system project report..pdf
Toll tax management system project report..pdfToll tax management system project report..pdf
Toll tax management system project report..pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
Introduction to Casting Processes in Manufacturing
Introduction to Casting Processes in ManufacturingIntroduction to Casting Processes in Manufacturing
Introduction to Casting Processes in Manufacturing
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
fundamentals of drawing and isometric and orthographic projection
fundamentals of drawing and isometric and orthographic projectionfundamentals of drawing and isometric and orthographic projection
fundamentals of drawing and isometric and orthographic projection
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Danfoss NeoCharge Technology -A Revolution in 2024.pdf
Danfoss NeoCharge Technology -A Revolution in 2024.pdfDanfoss NeoCharge Technology -A Revolution in 2024.pdf
Danfoss NeoCharge Technology -A Revolution in 2024.pdf
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 

APPLET.pptx

  • 2. Applet in Java Applet is a predefined class in java.applet package used to design distributed application. It is a client side technology. Applets are run on web browser. Advantage of Applet • Applets are supported by most web browsers. • Applets works on client side so less response time. • Secured: No access to the local machine and can only access the server it came from. • Easy to develop applet, just extends applet class. • To run applets, it requires the Java plug-in at client side. • Android, do not run Java applets. • Some applets require a specific JRE. If it required new JRE then it take more time to download new JRE. APPLET IN JAVA
  • 3. SCION RESEARCH AND DEVELOPMENT 3 Life cycle of applet init() start() stop destroy APPLET IN JAVA
  • 4. SCION RESEARCH AND DEVELOPMENT 4 init(): Which will be executed whenever an applet program start loading, it contains the logic to initiate the applet properties. start(): It will be executed whenever the applet program starts running. stop(): Which will be executed whenever the applet window or browser is minimized. destroy(): It will be executed whenever the applet window or browser is going to be closed (at the time of destroying the applet program permanently). APPLET IN JAVA
  • 5. SCION RESEARCH AND DEVELOPMENT 5 Design applet program We can design our own applet program by extending applet class in the user defined class. Syntax class className extends Applet { ...... // override lifecycle methods ...... } Note: Whenever an applet program is running init() and start() will be executed one after another, but stop() and destroy() will be executed if the browser is minimized and closed by the end user, respectively. Note: Applet program may or may not contain life cycle methods. APPLET IN JAVA
  • 6. SCION RESEARCH AND DEVELOPMENT 6 Running of applet programs Applet program can run in two ways. • Using html (in the web browser) • Using appletviewer tool (in applet window) Running of applet using html In general no Java program can directly execute on the web browser except markup language like html, xml etc. Html support a predefined tag called <applet> to load the applet program on the browser window. Syntax <applet code="udc.class"> height="100px" width="100px" </applet> APPLET IN JAVA
  • 7. SCION RESEARCH AND DEVELOPMENT 7 APPLET IN JAVA
  • 8. SCION RESEARCH AND DEVELOPMENT 8 APPLET IN JAVA
  • 9. SCION RESEARCH AND DEVELOPMENT 9 APPLET IN JAVA
  • 10. SCION RESEARCH AND DEVELOPMENT 10 APPLET IN JAVA
  • 11. SCION RESEARCH AND DEVELOPMENT 11 APPLET IN JAVA
  • 12. SCION RESEARCH AND DEVELOPMENT 12 APPLET IN JAVA
  • 13. SCION RESEARCH AND DEVELOPMENT 13 APPLET IN JAVA
  • 14. SCION RESEARCH AND DEVELOPMENT 14 APPLET IN JAVA
  • 15. SCION RESEARCH AND DEVELOPMENT 15 Example of applet program to run applet using html Java code, JavaApp.java import java.applet.*; import java.awt.*; public class JavaApp extends Applet { public void paint(Graphics g) { Font f=new Font("Arial",Font.BOLD,30); g.setFont(f); setForeground(Color.red); setBackground(Color.white); g.drawString("Student",200,200); } } Html code, myapplet.html <html> <title> AppletEx</Title> <body> <applet code="JavaApp.class" height="70%“ width="80%"> </applet> </body> </html> APPLET IN JAVA
  • 16. SCION RESEARCH AND DEVELOPMENT 16 If applet code not run on browser then allow blocked contents. Running of applet using appletviewer • Some browser does not support <applet> tag so that Sun MicroSystem was introduced a special tool called appletviewer to run the applet program. • In this Scenario Java program should contain <applet> tag in the commented lines so that appletviewer tools can run the current applet program. APPLET IN JAVA
  • 17. SCION RESEARCH AND DEVELOPMENT 17 Example of Applet import java.applet.*; import java.awt.*; /*<applet code="LifeApp.class" height="500“ ,width="800"> </applet>*/ public class LifeApp extends Applet { String s= " "; public void init() { s=s+ " int "; } public void start() { s=s+ "start "; APPLET IN JAVA
  • 18. SCION RESEARCH AND DEVELOPMENT 18 } public void stop() { s=s+ "stop "; } public void destroy() { s=s+ " destory "; } public void paint(Graphics g) { Font f=new Font("Arial",Font.BOLD,30); setBackgroundColor(Color."red"); g.setFont(f); g.drawString(s,200,250); } } APPLET IN JAVA
  • 19. SCION RESEARCH AND DEVELOPMENT 19 Execution of applet program javac LifeApp.javaappletviewer LifeApp.java Note: init() always execute only once at the time of loading applet window and also it will be executed if the applet is restarted. Factory Method in Java A factory method is one whose return type is similar to the class name in which class is present. The purpose of factory method is to create an object without using new operator. APPLET IN JAVA
  • 20. SCION RESEARCH AND DEVELOPMENT 20 Rules for writing factory method • The return type of the factory method must be similar to class name in which class it presents. • Every factory method in java is static. • The access specifies of the factory method must be public. APPLET IN JAVA