SlideShare a Scribd company logo
JAVA APPLET
By: PRIYANKA
PRADHAN
1
Applet
 An applet is a Java program that runs in a Web
browser. An applet can be a fully functional Java
application because it has the entire Java API at its
disposal.
PRIYANKA PRADHAN 2
Differences between an applet and
a standalone Java application.
 An applet is a Java class that extends the java.applet.Applet class.
 A main() method is not invoked on an applet, and an applet class will
not define main().
 Applets are designed to be embedded within an HTML page.
 When a user views an HTML page that contains an applet, the code for
the applet is downloaded to the user's machine.
 A JVM is required to view an applet. The JVM can be either a plug-in of
the Web browser or a separate runtime environment.
 The JVM on the user's machine creates an instance of the applet class
and invokes various methods during the applet's lifetime.
 Applets have strict security rules that are enforced by the Web browser.
PRIYANKA PRADHAN 3
Life Cycle of an Applet
 init − This method is intended for whatever initialization is needed for your applet. It is
called after the param tags inside the applet tag have been processed.
 start − This method is automatically called after the browser calls the init method. It is
also called whenever the user returns to the page containing the applet after having gone
off to other pages.
 stop − This method is automatically called when the user moves off the page on which
the applet sits. It can, therefore, be called repeatedly in the same applet.
 destroy − This method is only called when the browser shuts down normally. Because
applets are meant to live on an HTML page, you should not normally leave resources
behind after a user leaves the page that contains the applet.
 paint − Invoked immediately after the start() method, and also any time the applet needs
to repaint itself in the browser. The paint() method is actually inherited from the
java.awt.
PRIYANKA PRADHAN 4
Lifecycle methods for Applet:
 public void init(): is used to initialized the Applet. It
is invoked only once.
 public void start(): is invoked after the init() method
or browser is maximized. It is used to start the Applet.
 public void stop(): is used to stop the Applet. It is
invoked when Applet is stop or browser is minimized.
 public void destroy(): is used to destroy the Applet.
It is invoked only once.
PRIYANKA PRADHAN 5
java.awt.Component class
The Component class provides 1 life cycle method of
applet.
 public void paint(Graphics g): is used to paint the
Applet. It provides Graphics class object that can be
used for drawing oval, rectangle, arc etc.
PRIYANKA PRADHAN 6
How to run an Applet?
There are two ways to run an applet
 By html file.
 By appletViewer tool (for testing purpose).
PRIYANKA PRADHAN 7
//First.java
import java.applet.Applet;
import java.awt.Graphics;
public class First extends Applet{
public void paint(Graphics g){
g.drawString("welcome",150,150);
}
}
PRIYANKA PRADHAN 8
myapplet.html
<html>
<body>
<applet code="First.class" width="300" height="300">
</applet>
</body>
</html>
PRIYANKA PRADHAN 9
appletviewer tool:
 To execute the applet by appletviewer tool, create an
applet that contains applet tag in comment and
compile it. After that run it by: appletviewer First.java.
Now Html file is not required but it is for testing
purpose only.
PRIYANKA PRADHAN 10
//First.java
import java.applet.Applet;
import java.awt.Graphics;
public class First extends Applet{
public void paint(Graphics g){
g.drawString("welcome to applet",150,150);
}
}
/*
<applet code="First.class" width="300" height="300">
</applet>
*/
PRIYANKA PRADHAN 11
appletviewer tool, write in
command prompt:
 c:>javac First.java
 c:>appletviewer First.java
PRIYANKA PRADHAN 12
Displaying Graphics in Applet
 java.awt.Graphics class provides many methods for
graphics programming
PRIYANKA PRADHAN 13
Commonly used methods of Graphics class:
 public abstract void drawString(String str, int x, int y): is used to draw the specified
string.
 public void drawRect(int x, int y, int width, int height): draws a rectangle with the
specified width and height.
 public abstract void fillRect(int x, int y, int width, int height): is used to fill
rectangle with the default color and specified width and height.
 public abstract void drawOval(int x, int y, int width, int height): is used to draw oval
with the specified width and height.
 public abstract 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).
 public abstract boolean drawImage(Image img, int x, int y, ImageObserver
observer): is used draw the specified image.
PRIYANKA PRADHAN 14
Example of Graphics in applet:
import java.applet.Applet;
import java.awt.*;
public class GraphicsDemo extends Applet{
public void paint(Graphics g){
g.setColor(Color.red);
g.drawString("Welcome",50, 50);
g.drawLine(20,30,20,300);
g.drawRect(70,100,30,30);
g.fillRect(170,100,30,30);
g.drawOval(70,200,30,30);
g.setColor(Color.pink);
g.fillOval(170,200,30,30);
g.drawArc(90,150,30,30,30,270);
g.fillArc(270,150,30,30,0,180);
} } PRIYANKA PRADHAN 15
myapplet.html
<html>
<body>
<applet code="GraphicsDemo.class" width="300" height
="300">
</applet>
</body>
</html>
PRIYANKA PRADHAN 16
Displaying Image in Applet
import java.awt.*;
import java.applet.*;
public class DisplayImage extends Applet {
Image picture;
public void init() {
picture = getImage(getDocumentBase(),"sonoo.jpg");
}
public void paint(Graphics g) {
g.drawImage(picture, 30,30, this);
}
} PRIYANKA PRADHAN 17
myapplet.html
<html>
<body>
<applet code="DisplayImage.class" width="300" height=
"300">
</applet>
</body>
</html>
PRIYANKA PRADHAN 18
EventHandling in Applet
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class EventApplet extends Applet implements ActionListener{
Button b;
TextField tf;
public void init(){
tf=new TextField();
tf.setBounds(30,40,150,20);
b=new Button("Click");
b.setBounds(80,150,60,50);
add(b);add(tf);
b.addActionListener(this);
setLayout(null);
} public void actionPerformed(ActionEvent e){
tf.setText("Welcome");
} } PRIYANKA PRADHAN 19
myapplet.html
<html>
<body>
<applet code="EventApplet.class" width="300" height="3
00">
</applet>
</body>
</html>
PRIYANKA PRADHAN 20
Parameter in Applet
 We can get any information from the HTML file as a
parameter. For this purpose, Applet class provides a
method named getParameter(). Syntax:
 public String getParameter(String parameterName)
PRIYANKA PRADHAN 21
import java.applet.Applet;
import java.awt.Graphics;
public class UseParam extends Applet{
public void paint(Graphics g){
String str=getParameter("msg");
g.drawString(str,50, 50);
}
}
PRIYANKA PRADHAN 22
myapplet.html
<html>
<body>
<applet code="UseParam.class" width="300" height="300">
<param name="msg" value="Welcome to applet">
</applet>
</body>
</html>
PRIYANKA PRADHAN 23

More Related Content

What's hot

Applet progming
Applet progmingApplet progming
Applet progming
VIKRANTHMALLIKARJUN
 
Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
amitksaha
 
27 applet programming
27  applet programming27  applet programming
27 applet programming
Ravindra Rathore
 
java Applet Introduction
java Applet Introductionjava Applet Introduction
java Applet Introduction
yugandhar vadlamudi
 
Java Applet
Java AppletJava Applet
Java applets
Java appletsJava applets
Applets in java
Applets in javaApplets in java
Applets in java
Wani Zahoor
 
6.applet programming in java
6.applet programming in java6.applet programming in java
6.applet programming in java
Deepak Sharma
 
JAVA APPLET BASICS
JAVA APPLET BASICSJAVA APPLET BASICS
JAVA APPLET BASICS
Shanid Malayil
 
Graphics programming in Java
Graphics programming in JavaGraphics programming in Java
Graphics programming in Java
Tushar B Kute
 
Applet programming
Applet programming Applet programming
Applet programming
Devyani Vaidya
 
Java Applet and Graphics
Java Applet and GraphicsJava Applet and Graphics
Java Applet and Graphics
Abdul Rahman Sherzad
 
Applet life cycle
Applet life cycleApplet life cycle
Applet skelton58
Applet skelton58Applet skelton58
Applet skelton58
myrajendra
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
RamaPrabha24
 
ITFT- Applet in java
ITFT- Applet in javaITFT- Applet in java
ITFT- Applet in java
Atul Sehdev
 
Client Side Programming with Applet
Client Side Programming with AppletClient Side Programming with Applet
Client Side Programming with Applet
backdoor
 
Java applets
Java appletsJava applets
Java applets
M Vishnuvardhan Reddy
 
java Unit4 chapter1 applets
java Unit4 chapter1 appletsjava Unit4 chapter1 applets
java Unit4 chapter1 applets
raksharao
 
L18 applets
L18 appletsL18 applets
L18 applets
teach4uin
 

What's hot (20)

Applet progming
Applet progmingApplet progming
Applet progming
 
Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
 
27 applet programming
27  applet programming27  applet programming
27 applet programming
 
java Applet Introduction
java Applet Introductionjava Applet Introduction
java Applet Introduction
 
Java Applet
Java AppletJava Applet
Java Applet
 
Java applets
Java appletsJava applets
Java applets
 
Applets in java
Applets in javaApplets in java
Applets in java
 
6.applet programming in java
6.applet programming in java6.applet programming in java
6.applet programming in java
 
JAVA APPLET BASICS
JAVA APPLET BASICSJAVA APPLET BASICS
JAVA APPLET BASICS
 
Graphics programming in Java
Graphics programming in JavaGraphics programming in Java
Graphics programming in Java
 
Applet programming
Applet programming Applet programming
Applet programming
 
Java Applet and Graphics
Java Applet and GraphicsJava Applet and Graphics
Java Applet and Graphics
 
Applet life cycle
Applet life cycleApplet life cycle
Applet life cycle
 
Applet skelton58
Applet skelton58Applet skelton58
Applet skelton58
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
 
ITFT- Applet in java
ITFT- Applet in javaITFT- Applet in java
ITFT- Applet in java
 
Client Side Programming with Applet
Client Side Programming with AppletClient Side Programming with Applet
Client Side Programming with Applet
 
Java applets
Java appletsJava applets
Java applets
 
java Unit4 chapter1 applets
java Unit4 chapter1 appletsjava Unit4 chapter1 applets
java Unit4 chapter1 applets
 
L18 applets
L18 appletsL18 applets
L18 applets
 

Similar to Applet

Applet in java new
Applet in java newApplet in java new
Applet in java new
Kavitha713564
 
Basic of Applet
Basic of AppletBasic of Applet
Basic of Applet
suraj pandey
 
APPLET.pptx
APPLET.pptxAPPLET.pptx
APPLET.pptx
SHANMUGARAJA K
 
Java applet
Java appletJava applet
Java applet
Elizabeth alexander
 
Applet1 (1).pptx
Applet1 (1).pptxApplet1 (1).pptx
Applet1 (1).pptx
FahanaAbdulVahab
 
Applet (1)
Applet (1)Applet (1)
Applet (1)
DEEPIKA T
 
Java applet basics
Java applet basicsJava applet basics
Java applet basics
Sunil Pandey
 
oops with java modules iii & iv.pptx
oops with java modules iii & iv.pptxoops with java modules iii & iv.pptx
oops with java modules iii & iv.pptx
rani marri
 
Oops
OopsOops
Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01
Abhishek Khune
 
Smart material - Unit 3 (1).pdf
Smart material - Unit 3 (1).pdfSmart material - Unit 3 (1).pdf
Smart material - Unit 3 (1).pdf
GayathriRHICETCSESTA
 
Smart material - Unit 3 (2).pdf
Smart material - Unit 3 (2).pdfSmart material - Unit 3 (2).pdf
Smart material - Unit 3 (2).pdf
GayathriRHICETCSESTA
 
Applet
AppletApplet
Applet
Amir Shokri
 
Applet
 Applet Applet
Applet
swapnac12
 
Appletjava
AppletjavaAppletjava
Appletjava
DEEPIKA T
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
Gary Mendonca
 
Unit 7 Java
Unit 7 JavaUnit 7 Java
Unit 7 Java
arnold 7490
 
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 chapter 7
Java chapter 7Java chapter 7
Java chapter 7
Abdii Rashid
 
Java Applets
Java AppletsJava Applets

Similar to Applet (20)

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
 
APPLET.pptx
APPLET.pptxAPPLET.pptx
APPLET.pptx
 
Java applet
Java appletJava applet
Java applet
 
Applet1 (1).pptx
Applet1 (1).pptxApplet1 (1).pptx
Applet1 (1).pptx
 
Applet (1)
Applet (1)Applet (1)
Applet (1)
 
Java applet basics
Java applet basicsJava applet basics
Java applet basics
 
oops with java modules iii & iv.pptx
oops with java modules iii & iv.pptxoops with java modules iii & iv.pptx
oops with java modules iii & iv.pptx
 
Oops
OopsOops
Oops
 
Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01
 
Smart material - Unit 3 (1).pdf
Smart material - Unit 3 (1).pdfSmart material - Unit 3 (1).pdf
Smart material - Unit 3 (1).pdf
 
Smart material - Unit 3 (2).pdf
Smart material - Unit 3 (2).pdfSmart material - Unit 3 (2).pdf
Smart material - Unit 3 (2).pdf
 
Applet
AppletApplet
Applet
 
Applet
 Applet Applet
Applet
 
Appletjava
AppletjavaAppletjava
Appletjava
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
 
Unit 7 Java
Unit 7 JavaUnit 7 Java
Unit 7 Java
 
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
 
Java chapter 7
Java chapter 7Java chapter 7
Java chapter 7
 
Java Applets
Java AppletsJava Applets
Java Applets
 

More from Priyanka Pradhan

Tomato disease detection using deep learning convolutional neural network
Tomato disease detection using deep learning convolutional neural networkTomato disease detection using deep learning convolutional neural network
Tomato disease detection using deep learning convolutional neural network
Priyanka Pradhan
 
Servlet
ServletServlet
Css
CssCss
Javascript
JavascriptJavascript
Javascript
Priyanka Pradhan
 
XML
XMLXML
programming with python ppt
programming with python pptprogramming with python ppt
programming with python ppt
Priyanka Pradhan
 
Core Java
Core JavaCore Java
Core Java
Priyanka Pradhan
 
Image Processing Based Signature Recognition and Verification Technique Using...
Image Processing Based Signature Recognition and Verification Technique Using...Image Processing Based Signature Recognition and Verification Technique Using...
Image Processing Based Signature Recognition and Verification Technique Using...
Priyanka Pradhan
 
GrayBox Testing and Crud Testing By: Er. Priyanka Pradhan
GrayBox Testing and Crud Testing By: Er. Priyanka PradhanGrayBox Testing and Crud Testing By: Er. Priyanka Pradhan
GrayBox Testing and Crud Testing By: Er. Priyanka Pradhan
Priyanka Pradhan
 
The agile requirements refinery(SRUM) by: Priyanka Pradhan
The agile requirements refinery(SRUM) by: Priyanka PradhanThe agile requirements refinery(SRUM) by: Priyanka Pradhan
The agile requirements refinery(SRUM) by: Priyanka Pradhan
Priyanka Pradhan
 
Social tagging and its trend
Social tagging and its trendSocial tagging and its trend
Social tagging and its trend
Priyanka Pradhan
 
Behavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanBehavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka Pradhan
Priyanka Pradhan
 
software product and its characteristics
software product and its characteristicssoftware product and its characteristics
software product and its characteristics
Priyanka Pradhan
 
EDI(ELECTRONIC DATA INTERCHANGE)
EDI(ELECTRONIC DATA INTERCHANGE)EDI(ELECTRONIC DATA INTERCHANGE)
EDI(ELECTRONIC DATA INTERCHANGE)
Priyanka Pradhan
 
collaborative tagging :-by Er. Priyanka Pradhan
collaborative tagging :-by Er. Priyanka Pradhancollaborative tagging :-by Er. Priyanka Pradhan
collaborative tagging :-by Er. Priyanka Pradhan
Priyanka Pradhan
 
Deploying java beans in jsp
Deploying java beans in jspDeploying java beans in jsp
Deploying java beans in jsp
Priyanka Pradhan
 
SOFTWARE PROCESS MONITORING AND AUDIT
SOFTWARE PROCESS MONITORING AND AUDITSOFTWARE PROCESS MONITORING AND AUDIT
SOFTWARE PROCESS MONITORING AND AUDIT
Priyanka Pradhan
 
Pcmm
PcmmPcmm
s/w metrics monitoring and control
s/w metrics monitoring and controls/w metrics monitoring and control
s/w metrics monitoring and control
Priyanka Pradhan
 

More from Priyanka Pradhan (19)

Tomato disease detection using deep learning convolutional neural network
Tomato disease detection using deep learning convolutional neural networkTomato disease detection using deep learning convolutional neural network
Tomato disease detection using deep learning convolutional neural network
 
Servlet
ServletServlet
Servlet
 
Css
CssCss
Css
 
Javascript
JavascriptJavascript
Javascript
 
XML
XMLXML
XML
 
programming with python ppt
programming with python pptprogramming with python ppt
programming with python ppt
 
Core Java
Core JavaCore Java
Core Java
 
Image Processing Based Signature Recognition and Verification Technique Using...
Image Processing Based Signature Recognition and Verification Technique Using...Image Processing Based Signature Recognition and Verification Technique Using...
Image Processing Based Signature Recognition and Verification Technique Using...
 
GrayBox Testing and Crud Testing By: Er. Priyanka Pradhan
GrayBox Testing and Crud Testing By: Er. Priyanka PradhanGrayBox Testing and Crud Testing By: Er. Priyanka Pradhan
GrayBox Testing and Crud Testing By: Er. Priyanka Pradhan
 
The agile requirements refinery(SRUM) by: Priyanka Pradhan
The agile requirements refinery(SRUM) by: Priyanka PradhanThe agile requirements refinery(SRUM) by: Priyanka Pradhan
The agile requirements refinery(SRUM) by: Priyanka Pradhan
 
Social tagging and its trend
Social tagging and its trendSocial tagging and its trend
Social tagging and its trend
 
Behavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanBehavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka Pradhan
 
software product and its characteristics
software product and its characteristicssoftware product and its characteristics
software product and its characteristics
 
EDI(ELECTRONIC DATA INTERCHANGE)
EDI(ELECTRONIC DATA INTERCHANGE)EDI(ELECTRONIC DATA INTERCHANGE)
EDI(ELECTRONIC DATA INTERCHANGE)
 
collaborative tagging :-by Er. Priyanka Pradhan
collaborative tagging :-by Er. Priyanka Pradhancollaborative tagging :-by Er. Priyanka Pradhan
collaborative tagging :-by Er. Priyanka Pradhan
 
Deploying java beans in jsp
Deploying java beans in jspDeploying java beans in jsp
Deploying java beans in jsp
 
SOFTWARE PROCESS MONITORING AND AUDIT
SOFTWARE PROCESS MONITORING AND AUDITSOFTWARE PROCESS MONITORING AND AUDIT
SOFTWARE PROCESS MONITORING AND AUDIT
 
Pcmm
PcmmPcmm
Pcmm
 
s/w metrics monitoring and control
s/w metrics monitoring and controls/w metrics monitoring and control
s/w metrics monitoring and control
 

Recently uploaded

spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
An Introduction to the Compiler Designss
An Introduction to the Compiler DesignssAn Introduction to the Compiler Designss
An Introduction to the Compiler Designss
ElakkiaU
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
Atif Razi
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
People as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimalaPeople as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimala
riddhimaagrawal986
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
21UME003TUSHARDEB
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
Gino153088
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
UReason
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
ydzowc
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
bjmsejournal
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
SakkaravarthiShanmug
 
CEC 352 - SATELLITE COMMUNICATION UNIT 1
CEC 352 - SATELLITE COMMUNICATION UNIT 1CEC 352 - SATELLITE COMMUNICATION UNIT 1
CEC 352 - SATELLITE COMMUNICATION UNIT 1
PKavitha10
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
Seminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptxSeminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptx
Madan Karki
 
AI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptxAI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptx
architagupta876
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 

Recently uploaded (20)

spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
An Introduction to the Compiler Designss
An Introduction to the Compiler DesignssAn Introduction to the Compiler Designss
An Introduction to the Compiler Designss
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
People as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimalaPeople as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimala
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
 
CEC 352 - SATELLITE COMMUNICATION UNIT 1
CEC 352 - SATELLITE COMMUNICATION UNIT 1CEC 352 - SATELLITE COMMUNICATION UNIT 1
CEC 352 - SATELLITE COMMUNICATION UNIT 1
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
Seminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptxSeminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptx
 
AI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptxAI assisted telemedicine KIOSK for Rural India.pptx
AI assisted telemedicine KIOSK for Rural India.pptx
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 

Applet

  • 2. Applet  An applet is a Java program that runs in a Web browser. An applet can be a fully functional Java application because it has the entire Java API at its disposal. PRIYANKA PRADHAN 2
  • 3. Differences between an applet and a standalone Java application.  An applet is a Java class that extends the java.applet.Applet class.  A main() method is not invoked on an applet, and an applet class will not define main().  Applets are designed to be embedded within an HTML page.  When a user views an HTML page that contains an applet, the code for the applet is downloaded to the user's machine.  A JVM is required to view an applet. The JVM can be either a plug-in of the Web browser or a separate runtime environment.  The JVM on the user's machine creates an instance of the applet class and invokes various methods during the applet's lifetime.  Applets have strict security rules that are enforced by the Web browser. PRIYANKA PRADHAN 3
  • 4. Life Cycle of an Applet  init − This method is intended for whatever initialization is needed for your applet. It is called after the param tags inside the applet tag have been processed.  start − This method is automatically called after the browser calls the init method. It is also called whenever the user returns to the page containing the applet after having gone off to other pages.  stop − This method is automatically called when the user moves off the page on which the applet sits. It can, therefore, be called repeatedly in the same applet.  destroy − This method is only called when the browser shuts down normally. Because applets are meant to live on an HTML page, you should not normally leave resources behind after a user leaves the page that contains the applet.  paint − Invoked immediately after the start() method, and also any time the applet needs to repaint itself in the browser. The paint() method is actually inherited from the java.awt. PRIYANKA PRADHAN 4
  • 5. Lifecycle methods for Applet:  public void init(): is used to initialized the Applet. It is invoked only once.  public void start(): is invoked after the init() method or browser is maximized. It is used to start the Applet.  public void stop(): is used to stop the Applet. It is invoked when Applet is stop or browser is minimized.  public void destroy(): is used to destroy the Applet. It is invoked only once. PRIYANKA PRADHAN 5
  • 6. java.awt.Component class The Component class provides 1 life cycle method of applet.  public void paint(Graphics g): is used to paint the Applet. It provides Graphics class object that can be used for drawing oval, rectangle, arc etc. PRIYANKA PRADHAN 6
  • 7. How to run an Applet? There are two ways to run an applet  By html file.  By appletViewer tool (for testing purpose). PRIYANKA PRADHAN 7
  • 8. //First.java import java.applet.Applet; import java.awt.Graphics; public class First extends Applet{ public void paint(Graphics g){ g.drawString("welcome",150,150); } } PRIYANKA PRADHAN 8
  • 9. myapplet.html <html> <body> <applet code="First.class" width="300" height="300"> </applet> </body> </html> PRIYANKA PRADHAN 9
  • 10. appletviewer tool:  To execute the applet by appletviewer tool, create an applet that contains applet tag in comment and compile it. After that run it by: appletviewer First.java. Now Html file is not required but it is for testing purpose only. PRIYANKA PRADHAN 10
  • 11. //First.java import java.applet.Applet; import java.awt.Graphics; public class First extends Applet{ public void paint(Graphics g){ g.drawString("welcome to applet",150,150); } } /* <applet code="First.class" width="300" height="300"> </applet> */ PRIYANKA PRADHAN 11
  • 12. appletviewer tool, write in command prompt:  c:>javac First.java  c:>appletviewer First.java PRIYANKA PRADHAN 12
  • 13. Displaying Graphics in Applet  java.awt.Graphics class provides many methods for graphics programming PRIYANKA PRADHAN 13
  • 14. Commonly used methods of Graphics class:  public abstract void drawString(String str, int x, int y): is used to draw the specified string.  public void drawRect(int x, int y, int width, int height): draws a rectangle with the specified width and height.  public abstract void fillRect(int x, int y, int width, int height): is used to fill rectangle with the default color and specified width and height.  public abstract void drawOval(int x, int y, int width, int height): is used to draw oval with the specified width and height.  public abstract 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).  public abstract boolean drawImage(Image img, int x, int y, ImageObserver observer): is used draw the specified image. PRIYANKA PRADHAN 14
  • 15. Example of Graphics in applet: import java.applet.Applet; import java.awt.*; public class GraphicsDemo extends Applet{ public void paint(Graphics g){ g.setColor(Color.red); g.drawString("Welcome",50, 50); g.drawLine(20,30,20,300); g.drawRect(70,100,30,30); g.fillRect(170,100,30,30); g.drawOval(70,200,30,30); g.setColor(Color.pink); g.fillOval(170,200,30,30); g.drawArc(90,150,30,30,30,270); g.fillArc(270,150,30,30,0,180); } } PRIYANKA PRADHAN 15
  • 16. myapplet.html <html> <body> <applet code="GraphicsDemo.class" width="300" height ="300"> </applet> </body> </html> PRIYANKA PRADHAN 16
  • 17. Displaying Image in Applet import java.awt.*; import java.applet.*; public class DisplayImage extends Applet { Image picture; public void init() { picture = getImage(getDocumentBase(),"sonoo.jpg"); } public void paint(Graphics g) { g.drawImage(picture, 30,30, this); } } PRIYANKA PRADHAN 17
  • 18. myapplet.html <html> <body> <applet code="DisplayImage.class" width="300" height= "300"> </applet> </body> </html> PRIYANKA PRADHAN 18
  • 19. EventHandling in Applet import java.applet.*; import java.awt.*; import java.awt.event.*; public class EventApplet extends Applet implements ActionListener{ Button b; TextField tf; public void init(){ tf=new TextField(); tf.setBounds(30,40,150,20); b=new Button("Click"); b.setBounds(80,150,60,50); add(b);add(tf); b.addActionListener(this); setLayout(null); } public void actionPerformed(ActionEvent e){ tf.setText("Welcome"); } } PRIYANKA PRADHAN 19
  • 20. myapplet.html <html> <body> <applet code="EventApplet.class" width="300" height="3 00"> </applet> </body> </html> PRIYANKA PRADHAN 20
  • 21. Parameter in Applet  We can get any information from the HTML file as a parameter. For this purpose, Applet class provides a method named getParameter(). Syntax:  public String getParameter(String parameterName) PRIYANKA PRADHAN 21
  • 22. import java.applet.Applet; import java.awt.Graphics; public class UseParam extends Applet{ public void paint(Graphics g){ String str=getParameter("msg"); g.drawString(str,50, 50); } } PRIYANKA PRADHAN 22
  • 23. myapplet.html <html> <body> <applet code="UseParam.class" width="300" height="300"> <param name="msg" value="Welcome to applet"> </applet> </body> </html> PRIYANKA PRADHAN 23