SlideShare a Scribd company logo
1 of 14
Applet in Java
What is Applet
Applets are the dynamic client site components which
runs on the browser.
Client site components are used to forward request of
the user to server.
Features of Applets
•Runs only on client site
•Runs on browser
•Applet program does not require main
function
•Applets are dynamic
•Applet class is always public so that it can
call from outside
•To run applet HTML code is required
Limitation of Applets
•Applets are Heavy weight components
•Dependent on operating system
•Typical Java Coding
•Require plug-in to run on browser
Applet Life Cycle
Built-in Classes for Applet
To implement applet life cycle:
Applet class
Package: java.applet
To graphics design in the applet :
Graphics class
Package: java.awt
Applet Life Cycle Methods
Init : public void init()
-use to write the initialize code
Start : public void start()
-This method starts the applet
Paint : public void paint(Graphics obj)
-This method paint the contents on the applet
- Graphics class is awt class and use as parameter of paint method.
Stop : public void stop()
- This method stop the applet. Stopped applet can restart later by
start() method
Destroy : public void destroy()
- This method destroy the applet permanently. Once applet is
destroy it can’t be start.
Methods of Graphics class
void drawString(String str, int x, int y): is used to draw the specified string.
void drawRect(int x, int y, int width, int height): draws a rectangle with the
specified width and height.
void fillRect(int x, int y, int width, int height): is used to fill rectangle with the
default color and specified width and height.
 void drawOval(int x, int y, int width, int height): is used to draw oval with the
specified width and height.
void fillOval(int x, int y, int width, int height): is used to fill oval with the default
color and specified width and height.
public abstract void drawLine(int x1, int y1, int x2, int y2): is used to draw line
between the points(x1, y1) and (x2, y2).
boolean drawImage(Image img, int x, int y, ImageObserver observer): is used
draw the specified image.
public abstract void drawArc(int x, int y, int width, int height, int startAngle,
int arcAngle): is used draw a circular or elliptical arc.
public abstract void fillArc(int x, int y, int width, int height, int startAngle, int
arcAngle): is used to fill a circular or elliptical arc.
public abstract void setColor(Color c): is used to set the graphics current color
to the specified color.
public abstract void setFont(Font font): is used to set the graphics current font
to the specified font.
Methods of Graphics class - 2
How to run Applet
Applet can be run through HTML file with code :
<Applet Code = “Applet class name" Width = "400" Height =
"400"></Applet>
This code can be embedded in java code as comments :
/* <Applet Code = “Applet class name" Width = "400" Height = "400">
</Applet> */
Applet Viewer
It is utility provided by Java to debug and run the
Java Applet.
C:>Appletviewer HTML/Class file name
import java.applet.*;
import java.awt.Graphics;
import java.awt.Color;
import java.util.*;
public class TestApplet extends Applet
{
/*<Applet Code = "TestApplet.class" Width = "400" Height = "400"></Applet> */
public void init()
{
setBackground(Color.black);
setForeground(Color.yellow);
}
public void paint(Graphics g)
{ Date dt = new Date();
g.drawString("Hello",20,40);
g.drawString(dt,30,50);
}
}
<html>
<body>
<h1>This is Applet</h1>
<Applet Code = "TestApplet.class" Width =
"400" Height = "400"></Applet>
</body>
</html>
Applet in java

More Related Content

What's hot

Abstraction in java
Abstraction in javaAbstraction in java
Abstraction in javasawarkar17
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1PRN USM
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methodsShubham Dwivedi
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in javaTech_MX
 
Java Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPRECJava Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPRECSreedhar Chowdam
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVAAbhilash Nair
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programmingsrijavel
 
L21 io streams
L21 io streamsL21 io streams
L21 io streamsteach4uin
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Elizabeth alexander
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handlingkamal kotecha
 
Introduction to method overloading &amp; method overriding in java hdm
Introduction to method overloading &amp; method overriding  in java  hdmIntroduction to method overloading &amp; method overriding  in java  hdm
Introduction to method overloading &amp; method overriding in java hdmHarshal Misalkar
 
2.2 turtle graphics
2.2   turtle graphics2.2   turtle graphics
2.2 turtle graphicsallenbailey
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in javaNilesh Dalvi
 
Computer graphics presentation
Computer graphics presentationComputer graphics presentation
Computer graphics presentationLOKENDRA PRAJAPATI
 

What's hot (20)

Java applet
Java appletJava applet
Java applet
 
Abstraction in java
Abstraction in javaAbstraction in java
Abstraction in java
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Generics in java
Generics in javaGenerics in java
Generics in java
 
c++ lab manual
c++ lab manualc++ lab manual
c++ lab manual
 
Interface in java
Interface in javaInterface in java
Interface in java
 
Java Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPRECJava Notes by C. Sreedhar, GPREC
Java Notes by C. Sreedhar, GPREC
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
 
L21 io streams
L21 io streamsL21 io streams
L21 io streams
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Introduction to method overloading &amp; method overriding in java hdm
Introduction to method overloading &amp; method overriding  in java  hdmIntroduction to method overloading &amp; method overriding  in java  hdm
Introduction to method overloading &amp; method overriding in java hdm
 
2.2 turtle graphics
2.2   turtle graphics2.2   turtle graphics
2.2 turtle graphics
 
Method parameters in c#
Method parameters in c#Method parameters in c#
Method parameters in c#
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
 
Java-java virtual machine
Java-java virtual machineJava-java virtual machine
Java-java virtual machine
 
Computer graphics presentation
Computer graphics presentationComputer graphics presentation
Computer graphics presentation
 

Similar to Applet in java (20)

Java chapter 7
Java chapter 7Java chapter 7
Java chapter 7
 
L18 applets
L18 appletsL18 applets
L18 applets
 
Applet in java new
Applet in java newApplet in java new
Applet in java new
 
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
 
Applets
AppletsApplets
Applets
 
JAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdfJAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdf
 
Displaying information within a window.68
Displaying information within a window.68Displaying information within a window.68
Displaying information within a window.68
 
GUI.pdf
GUI.pdfGUI.pdf
GUI.pdf
 
Java applet
Java appletJava applet
Java applet
 
U5 JAVA.pptx
U5 JAVA.pptxU5 JAVA.pptx
U5 JAVA.pptx
 
Applet (1)
Applet (1)Applet (1)
Applet (1)
 
java Applet Introduction
java Applet Introductionjava Applet Introduction
java Applet Introduction
 
Applets 101-fa06
Applets 101-fa06Applets 101-fa06
Applets 101-fa06
 
Applets
AppletsApplets
Applets
 
Unit 7 Java
Unit 7 JavaUnit 7 Java
Unit 7 Java
 
Oops
OopsOops
Oops
 
Client Side Programming with Applet
Client Side Programming with AppletClient Side Programming with Applet
Client Side Programming with Applet
 
Session4 applets
Session4   appletsSession4   applets
Session4 applets
 

Recently uploaded

How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 

Recently uploaded (20)

How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 

Applet in java

  • 2. What is Applet Applets are the dynamic client site components which runs on the browser. Client site components are used to forward request of the user to server.
  • 3. Features of Applets •Runs only on client site •Runs on browser •Applet program does not require main function •Applets are dynamic •Applet class is always public so that it can call from outside •To run applet HTML code is required
  • 4. Limitation of Applets •Applets are Heavy weight components •Dependent on operating system •Typical Java Coding •Require plug-in to run on browser
  • 6. Built-in Classes for Applet To implement applet life cycle: Applet class Package: java.applet To graphics design in the applet : Graphics class Package: java.awt
  • 7. Applet Life Cycle Methods Init : public void init() -use to write the initialize code Start : public void start() -This method starts the applet Paint : public void paint(Graphics obj) -This method paint the contents on the applet - Graphics class is awt class and use as parameter of paint method. Stop : public void stop() - This method stop the applet. Stopped applet can restart later by start() method Destroy : public void destroy() - This method destroy the applet permanently. Once applet is destroy it can’t be start.
  • 8. Methods of Graphics class void drawString(String str, int x, int y): is used to draw the specified string. void drawRect(int x, int y, int width, int height): draws a rectangle with the specified width and height. void fillRect(int x, int y, int width, int height): is used to fill rectangle with the default color and specified width and height.  void drawOval(int x, int y, int width, int height): is used to draw oval with the specified width and height. void fillOval(int x, int y, int width, int height): is used to fill oval with the default color and specified width and height. public abstract void drawLine(int x1, int y1, int x2, int y2): is used to draw line between the points(x1, y1) and (x2, y2). boolean drawImage(Image img, int x, int y, ImageObserver observer): is used draw the specified image.
  • 9. public abstract void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle): is used draw a circular or elliptical arc. public abstract void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle): is used to fill a circular or elliptical arc. public abstract void setColor(Color c): is used to set the graphics current color to the specified color. public abstract void setFont(Font font): is used to set the graphics current font to the specified font. Methods of Graphics class - 2
  • 10. How to run Applet Applet can be run through HTML file with code : <Applet Code = “Applet class name" Width = "400" Height = "400"></Applet> This code can be embedded in java code as comments : /* <Applet Code = “Applet class name" Width = "400" Height = "400"> </Applet> */
  • 11. Applet Viewer It is utility provided by Java to debug and run the Java Applet. C:>Appletviewer HTML/Class file name
  • 12. import java.applet.*; import java.awt.Graphics; import java.awt.Color; import java.util.*; public class TestApplet extends Applet { /*<Applet Code = "TestApplet.class" Width = "400" Height = "400"></Applet> */ public void init() { setBackground(Color.black); setForeground(Color.yellow); } public void paint(Graphics g) { Date dt = new Date(); g.drawString("Hello",20,40); g.drawString(dt,30,50); } }
  • 13. <html> <body> <h1>This is Applet</h1> <Applet Code = "TestApplet.class" Width = "400" Height = "400"></Applet> </body> </html>