SlideShare ist ein Scribd-Unternehmen logo
1 von 20
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

Weitere ähnliche Inhalte

Ähnlich wie APPLET.pptx

Ähnlich wie 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 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)
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
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
 

Kürzlich hochgeladen

S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxSCMS School of Architecture
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
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
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086anil_gaur
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwaitjaanualu31
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network DevicesChandrakantDivate1
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksMagic Marks
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesMayuraD1
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersMairaAshraf6
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdfKamal Acharya
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 

Kürzlich hochgeladen (20)

S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
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
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic Marks
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 

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