SlideShare a Scribd company logo
2
Most read
7
Most read
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

PDF
Files in java
Muthukumaran Subramanian
 
PDF
Introduction to basics of java
vinay arora
 
PPTX
Packages in java
Elizabeth alexander
 
PPT
Java EE Introduction
ejlp12
 
PPTX
Java awt (abstract window toolkit)
Elizabeth alexander
 
PPTX
Static Members-Java.pptx
ADDAGIRIVENKATARAVIC
 
PDF
Applets
Prabhakaran V M
 
Introduction to basics of java
vinay arora
 
Packages in java
Elizabeth alexander
 
Java EE Introduction
ejlp12
 
Java awt (abstract window toolkit)
Elizabeth alexander
 
Static Members-Java.pptx
ADDAGIRIVENKATARAVIC
 

What's hot (20)

PPT
Creating a frame within an applet
myrajendra
 
PPS
Java Exception handling
kamal kotecha
 
PDF
Introduction to Java Programming Language
jaimefrozr
 
PPTX
Java Method, Static Block
Infoviaan Technologies
 
PPTX
Oop c++class(final).ppt
Alok Kumar
 
PPTX
This keyword in java
Hitesh Kumar
 
PDF
Java threads
Prabhakaran V M
 
PPTX
Java Data Types
Spotle.ai
 
PPTX
JAVA AWT
shanmuga rajan
 
PDF
Introduction to java (revised)
Sujit Majety
 
PPTX
I/O Streams
Ravi Chythanya
 
PPTX
Inheritance In Java
Manish Sahu
 
PPTX
Advance Java Topics (J2EE)
slire
 
PPTX
Adapter Design Pattern
Shahriar Iqbal Chowdhury
 
PPT
Java: GUI
Tareq Hasan
 
PPTX
MULTI THREADING IN JAVA
VINOTH R
 
PPTX
File handling
priya_trehan
 
PPTX
Applets in java
Wani Zahoor
 
PPTX
Event Handling in java
Google
 
PDF
JavaScript Execution Context
Juan Medina
 
Creating a frame within an applet
myrajendra
 
Java Exception handling
kamal kotecha
 
Introduction to Java Programming Language
jaimefrozr
 
Java Method, Static Block
Infoviaan Technologies
 
Oop c++class(final).ppt
Alok Kumar
 
This keyword in java
Hitesh Kumar
 
Java threads
Prabhakaran V M
 
Java Data Types
Spotle.ai
 
JAVA AWT
shanmuga rajan
 
Introduction to java (revised)
Sujit Majety
 
I/O Streams
Ravi Chythanya
 
Inheritance In Java
Manish Sahu
 
Advance Java Topics (J2EE)
slire
 
Adapter Design Pattern
Shahriar Iqbal Chowdhury
 
Java: GUI
Tareq Hasan
 
MULTI THREADING IN JAVA
VINOTH R
 
File handling
priya_trehan
 
Applets in java
Wani Zahoor
 
Event Handling in java
Google
 
JavaScript Execution Context
Juan Medina
 
Ad

Similar to Applet in java (20)

PPTX
Java Applet presentation............pptx
ZaildarHussainFaisal
 
PPTX
Java chapter 7
Abdii Rashid
 
PPTX
Applet in java new
Kavitha713564
 
PPTX
Applet
Priyanka Pradhan
 
PPT
Basic of Applet
suraj pandey
 
PPTX
L18 applets
teach4uin
 
PPTX
Applet life cycle
V.V.Vanniapermal College for Women
 
PPT
Applets
Abhishek Khune
 
PPT
Applets
Inayat Sharma
 
PPTX
Introduction To Applets methods and simple examples
MsPariyalNituLaxman
 
PPT
Applets
SanthiNivas
 
PPT
Applets(1)cusdhsiohisdhfshihfsihfohf.ppt
Vijay Bhaskar Thatty
 
PPT
Appletsbjhbjiibibibikbibibjibjbibbjb.ppt
Vijay Bhaskar Thatty
 
PPTX
Applet and graphics programming
srijavel
 
PPTX
Java Apple dndkorksnsbsjdkkdjejdjrdndjdj
midhunmsd143
 
PPT
Introduction to Java Applet and Life cycle of an Applet
muthulakshmi279332
 
PPSX
Java Applet
jalinder123
 
PPT
Applet ppt for higher understanding education
BhanuPriya93439
 
PPT
java programming - applets
HarshithaAllu
 
PPTX
Applets
Nuha Noor
 
Java Applet presentation............pptx
ZaildarHussainFaisal
 
Java chapter 7
Abdii Rashid
 
Applet in java new
Kavitha713564
 
Basic of Applet
suraj pandey
 
L18 applets
teach4uin
 
Applets
Inayat Sharma
 
Introduction To Applets methods and simple examples
MsPariyalNituLaxman
 
Applets
SanthiNivas
 
Applets(1)cusdhsiohisdhfshihfsihfohf.ppt
Vijay Bhaskar Thatty
 
Appletsbjhbjiibibibikbibibjibjbibbjb.ppt
Vijay Bhaskar Thatty
 
Applet and graphics programming
srijavel
 
Java Apple dndkorksnsbsjdkkdjejdjrdndjdj
midhunmsd143
 
Introduction to Java Applet and Life cycle of an Applet
muthulakshmi279332
 
Java Applet
jalinder123
 
Applet ppt for higher understanding education
BhanuPriya93439
 
java programming - applets
HarshithaAllu
 
Applets
Nuha Noor
 
Ad

Recently uploaded (20)

PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PPTX
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
DOCX
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
PPTX
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PPTX
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PDF
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PPTX
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
PPTX
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
PDF
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
PDF
Biological Classification Class 11th NCERT CBSE NEET.pdf
NehaRohtagi1
 
PPTX
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
Biological Classification Class 11th NCERT CBSE NEET.pdf
NehaRohtagi1
 
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 

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>