SlideShare a Scribd company logo
Java Applet
Objectives
• Definition
• Use of Java
• Advantages
• Methods
• Life Cycle
• Examples
• Drawback
What Is Applet?
An Applet is a special kind of java program that is designed to be transmitted
over the internet and automatically executed by java compatible web browser.
Why We Use Applet In Java?
• Java Applets are usually used to add small, interactive components
or enhancements to a webpage. These may consist of buttons,
scrolling text, or stock tickers, but they can also be used to display
larger programs like word processors or games.
Advantages of Applet in Java
• There are many advantages of applet. They are as follows:
• It works at client side so less response time.
• Secured
• It can be executed by browsers running under many plateforms,
including Linux, Windows, Mac Os etc.
How to run an Applet?
• By html file.
• By appletViewer tool (for testing purpose).
Applet Header Files
• import java.applet.*
• import java.awt.*
Methods
Function Use
init() is used to initialized the Applet. It is invoked only
once
start() is invoked after the init() method or browser is
maximized. It is used to start the Applet.
stop() is used to stop the Applet. It is invoked when
Applet is stop or browser is minimized.
destroy() is used to destroy the Applet. It is invoked only
once.
paint() is used to paint the Applet
init()
The init() method is the first method to be
called
import java.applet.Applet;
public class First extends Applet {
public void init() {
}
}
paint()
import java.applet.Applet;
import java.awt.Graphics;
public class First extends Applet {
public void paint(Graphics g){
g.drawString("Welcome To Our
Presentation", 100, 75);
}
}
Example :01
import java.applet.*;
import java.awt.*;
public class Drawline extends Applet {
public void init() {
}
public void paint(Graphics g){
g.drawLine(20,20,100,20);
g.drawLine(20,20,20,100);
}
}
Example 02
import java.applet.Applet;
import java.awt.*;
public class RECt extends Applet {
public void init() {
}
public void paint(Graphics g){
g.drawRect(70,50,300,200);
}
}
Example 03
import java.applet*;
import java.awt.*;
public class Backcolor extends Applet {
public void init(){
setBackground(Color.blue);
}
public void paint(Graphics g) {
g.setColor(Color.white);
g.drawString("JAVA APPLET",40,100);
}
}
Example 04
import java.applet.Applet;
import java.awt.*;
import java.awt.Image;
public class Image_OP extends Applet {
Image picture;
public void init() {
picture=getImage(getDocumentBase(),"JKKNIU.jpg");
}
public void paint(Graphics g){
g.drawImage(picture,50,50,this);
}
}
Example 05
package applete;
import java.applet.Applet;
import java.awt.*;
public class Second extends Applet{
public void paint(Graphics g){
g.setColor(Color.red);
g.drawString("Welcome",150, 70);
g.drawRect(70,100,40,30);
g.fillRect(170,100,30,30);
g.drawOval(70,200,30,30);
g.setColor(Color.pink);
g.drawString("Welcome to my applete program",50, 50);
g.fillOval(170,200,30,30);
g.drawArc(90,150,30,30,30,270);
g.fillArc(270,150,30,30,0,180);
}
}
Example 06
package applete;
import java.applet.*;
import javax.swing.*;
import java.awt.event.*;
public class EventApplet extends JApplet implements ActionListener{
JButton b;
JTextField tf;
public void init(){
tf=new JTextField();
tf.setBounds(30,40,150,20);
b=new JButton("Click");
b.setBounds(80,150,70,40);
add(b);add(tf);
b.addActionListener(this);
setLayout(null);
}
public void actionPerformed(ActionEvent e){
tf.setText("Welcome");
}
}
Example 07
package applete;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Painting extends Applet implements MouseMotionListener{
public void init(){
addMouseMotionListener(this);
setBackground(Color.red);
}
public void mouseDragged(MouseEvent me){
Graphics g=getGraphics();
g.setColor(Color.white);
g.fillOval(me.getX(),me.getY(),5,5);
}
public void mouseMoved(MouseEvent me){}
}
Example 08
Example 09
Drawback of Applet
• Plugin is required at client browser to execute applet

More Related Content

What's hot

Applets in java
Applets in javaApplets in java
Applets in java
Wani Zahoor
 
Wrapper class
Wrapper classWrapper class
Wrapper class
kamal kotecha
 
String in java
String in javaString in java
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
Nilesh Dalvi
 
Constants in java
Constants in javaConstants in java
Constants in java
Manojkumar C
 
Data types in java
Data types in javaData types in java
Data types in java
HarshitaAshwani
 
I/O Streams
I/O StreamsI/O Streams
I/O Streams
Ravi Chythanya
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
lalithambiga kamaraj
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
Niloy Saha
 
String and string buffer
String and string bufferString and string buffer
String and string buffer
kamal kotecha
 
Control flow statements in java
Control flow statements in javaControl flow statements in java
Control flow statements in java
yugandhar vadlamudi
 
Exception handling
Exception handling Exception handling
Exception handling
M Vishnuvardhan Reddy
 
Java String class
Java String classJava String class
Java String class
DrRajeshreeKhande
 
Method overloading
Method overloadingMethod overloading
Method overloading
Lovely Professional University
 
Java threads
Java threadsJava threads
Java threads
Prabhakaran V M
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
bhavesh prakash
 
Collections - Lists, Sets
Collections - Lists, Sets Collections - Lists, Sets
Collections - Lists, Sets
Hitesh-Java
 
String, string builder, string buffer
String, string builder, string bufferString, string builder, string buffer
String, string builder, string buffer
SSN College of Engineering, Kalavakkam
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
Abhilash Nair
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
kamal kotecha
 

What's hot (20)

Applets in java
Applets in javaApplets in java
Applets in java
 
Wrapper class
Wrapper classWrapper class
Wrapper class
 
String in java
String in javaString in java
String in java
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
 
Constants in java
Constants in javaConstants in java
Constants in java
 
Data types in java
Data types in javaData types in java
Data types in java
 
I/O Streams
I/O StreamsI/O Streams
I/O Streams
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
String and string buffer
String and string bufferString and string buffer
String and string buffer
 
Control flow statements in java
Control flow statements in javaControl flow statements in java
Control flow statements in java
 
Exception handling
Exception handling Exception handling
Exception handling
 
Java String class
Java String classJava String class
Java String class
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
Java threads
Java threadsJava threads
Java threads
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
 
Collections - Lists, Sets
Collections - Lists, Sets Collections - Lists, Sets
Collections - Lists, Sets
 
String, string builder, string buffer
String, string builder, string bufferString, string builder, string buffer
String, string builder, string buffer
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 

Similar to Java applet - java

Applet-Presentation-object-oriented-programming.pptx
Applet-Presentation-object-oriented-programming.pptxApplet-Presentation-object-oriented-programming.pptx
Applet-Presentation-object-oriented-programming.pptx
cibec63256
 
27 applet programming
27  applet programming27  applet programming
27 applet programming
Ravindra Rathore
 
Applet in java new
Applet in java newApplet in java new
Applet in java new
Kavitha713564
 
Applet
AppletApplet
java Applet Introduction
java Applet Introductionjava Applet Introduction
java Applet Introduction
yugandhar vadlamudi
 
applet.pptx
applet.pptxapplet.pptx
applet.pptx
SachinBhosale73
 
Java Applets
Java AppletsJava Applets
Applet
 Applet Applet
Applet
swapnac12
 
Basic of Applet
Basic of AppletBasic of Applet
Basic of Applet
suraj pandey
 
Applet progming
Applet progmingApplet progming
Applet progming
VIKRANTHMALLIKARJUN
 
Unit 7 Java
Unit 7 JavaUnit 7 Java
Unit 7 Java
arnold 7490
 
APPLET.pptx
APPLET.pptxAPPLET.pptx
APPLET.pptx
SHANMUGARAJA K
 
Java: Java Applets
Java: Java AppletsJava: Java Applets
Java: Java Applets
Tareq Hasan
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
Gary Mendonca
 
Jsp applet
Jsp appletJsp applet
Jsp applet
Sanoj Kumar
 
Applet
AppletApplet
Applet
Amir Shokri
 
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
SivaSankari36
 
Applet programming1
Applet programming1Applet programming1
Applet programming1
Shah Ishtiyaq Mehfooze
 
Oops
OopsOops
Java Applet
Java AppletJava Applet
Java Applet
Athharul Haq
 

Similar to Java applet - java (20)

Applet-Presentation-object-oriented-programming.pptx
Applet-Presentation-object-oriented-programming.pptxApplet-Presentation-object-oriented-programming.pptx
Applet-Presentation-object-oriented-programming.pptx
 
27 applet programming
27  applet programming27  applet programming
27 applet programming
 
Applet in java new
Applet in java newApplet in java new
Applet in java new
 
Applet
AppletApplet
Applet
 
java Applet Introduction
java Applet Introductionjava Applet Introduction
java Applet Introduction
 
applet.pptx
applet.pptxapplet.pptx
applet.pptx
 
Java Applets
Java AppletsJava Applets
Java Applets
 
Applet
 Applet Applet
Applet
 
Basic of Applet
Basic of AppletBasic of Applet
Basic of Applet
 
Applet progming
Applet progmingApplet progming
Applet progming
 
Unit 7 Java
Unit 7 JavaUnit 7 Java
Unit 7 Java
 
APPLET.pptx
APPLET.pptxAPPLET.pptx
APPLET.pptx
 
Java: Java Applets
Java: Java AppletsJava: Java Applets
Java: Java Applets
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
 
Jsp applet
Jsp appletJsp applet
Jsp applet
 
Applet
AppletApplet
Applet
 
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
 
Applet programming1
Applet programming1Applet programming1
Applet programming1
 
Oops
OopsOops
Oops
 
Java Applet
Java AppletJava Applet
Java Applet
 

Recently uploaded

The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
sachin chaurasia
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
IJNSA Journal
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
mahammadsalmanmech
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
University of Maribor
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
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
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 
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
 
Recycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part IIRecycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part II
Aditya Rajan Patra
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
NazakatAliKhoso2
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
zubairahmad848137
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
KrishnaveniKrishnara1
 
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMTIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
HODECEDSIET
 
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)

The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 
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...
 
Recycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part IIRecycled Concrete Aggregate in Construction Part II
Recycled Concrete Aggregate in Construction Part II
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
 
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEMTIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
TIME DIVISION MULTIPLEXING TECHNIQUE FOR COMMUNICATION SYSTEM
 
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
 

Java applet - java

  • 1.
  • 3. Objectives • Definition • Use of Java • Advantages • Methods • Life Cycle • Examples • Drawback
  • 4. What Is Applet? An Applet is a special kind of java program that is designed to be transmitted over the internet and automatically executed by java compatible web browser.
  • 5. Why We Use Applet In Java? • Java Applets are usually used to add small, interactive components or enhancements to a webpage. These may consist of buttons, scrolling text, or stock tickers, but they can also be used to display larger programs like word processors or games.
  • 6. Advantages of Applet in Java • There are many advantages of applet. They are as follows: • It works at client side so less response time. • Secured • It can be executed by browsers running under many plateforms, including Linux, Windows, Mac Os etc.
  • 7. How to run an Applet? • By html file. • By appletViewer tool (for testing purpose).
  • 8. Applet Header Files • import java.applet.* • import java.awt.*
  • 9. Methods Function Use init() is used to initialized the Applet. It is invoked only once start() is invoked after the init() method or browser is maximized. It is used to start the Applet. stop() is used to stop the Applet. It is invoked when Applet is stop or browser is minimized. destroy() is used to destroy the Applet. It is invoked only once. paint() is used to paint the Applet
  • 10. init() The init() method is the first method to be called import java.applet.Applet; public class First extends Applet { public void init() { } }
  • 11. paint() import java.applet.Applet; import java.awt.Graphics; public class First extends Applet { public void paint(Graphics g){ g.drawString("Welcome To Our Presentation", 100, 75); } }
  • 12.
  • 13. Example :01 import java.applet.*; import java.awt.*; public class Drawline extends Applet { public void init() { } public void paint(Graphics g){ g.drawLine(20,20,100,20); g.drawLine(20,20,20,100); } }
  • 14. Example 02 import java.applet.Applet; import java.awt.*; public class RECt extends Applet { public void init() { } public void paint(Graphics g){ g.drawRect(70,50,300,200); } }
  • 15. Example 03 import java.applet*; import java.awt.*; public class Backcolor extends Applet { public void init(){ setBackground(Color.blue); } public void paint(Graphics g) { g.setColor(Color.white); g.drawString("JAVA APPLET",40,100); } }
  • 16. Example 04 import java.applet.Applet; import java.awt.*; import java.awt.Image; public class Image_OP extends Applet { Image picture; public void init() { picture=getImage(getDocumentBase(),"JKKNIU.jpg"); } public void paint(Graphics g){ g.drawImage(picture,50,50,this); } }
  • 17. Example 05 package applete; import java.applet.Applet; import java.awt.*; public class Second extends Applet{ public void paint(Graphics g){ g.setColor(Color.red); g.drawString("Welcome",150, 70); g.drawRect(70,100,40,30); g.fillRect(170,100,30,30); g.drawOval(70,200,30,30); g.setColor(Color.pink); g.drawString("Welcome to my applete program",50, 50); g.fillOval(170,200,30,30); g.drawArc(90,150,30,30,30,270); g.fillArc(270,150,30,30,0,180); } }
  • 18. Example 06 package applete; import java.applet.*; import javax.swing.*; import java.awt.event.*; public class EventApplet extends JApplet implements ActionListener{ JButton b; JTextField tf; public void init(){ tf=new JTextField(); tf.setBounds(30,40,150,20); b=new JButton("Click"); b.setBounds(80,150,70,40); add(b);add(tf); b.addActionListener(this); setLayout(null); } public void actionPerformed(ActionEvent e){ tf.setText("Welcome"); } }
  • 19. Example 07 package applete; import java.awt.*; import java.awt.event.*; import java.applet.*; public class Painting extends Applet implements MouseMotionListener{ public void init(){ addMouseMotionListener(this); setBackground(Color.red); } public void mouseDragged(MouseEvent me){ Graphics g=getGraphics(); g.setColor(Color.white); g.fillOval(me.getX(),me.getY(),5,5); } public void mouseMoved(MouseEvent me){} }
  • 22. Drawback of Applet • Plugin is required at client browser to execute applet