SlideShare a Scribd company logo
7
Most read
9
Most read
11
Most read
Java applet - java
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);
}
}
Java applet - java
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
Ad

Recommended

JAVA AWT
JAVA AWT
shanmuga rajan
 
String Handling
String Handling
Bharat17485
 
Applets
Applets
Prabhakaran V M
 
Threads in JAVA
Threads in JAVA
Haldia Institute of Technology
 
Static Members-Java.pptx
Static Members-Java.pptx
ADDAGIRIVENKATARAVIC
 
Type casting in java
Type casting in java
Farooq Baloch
 
I/O Streams
I/O Streams
Ravi Chythanya
 
Applet life cycle
Applet life cycle
myrajendra
 
Java string handling
Java string handling
Salman Khan
 
java interface and packages
java interface and packages
VINOTH R
 
Multithreading in java
Multithreading in java
Arafat Hossan
 
Files in java
Files in java
Muthukumaran Subramanian
 
Threads concept in java
Threads concept in java
Muthukumaran Subramanian
 
Java Networking
Java Networking
Sunil OS
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVA
VINOTH R
 
Multithreading in java
Multithreading in java
Monika Mishra
 
Event Handling in java
Event Handling in java
Google
 
Introduction to matplotlib
Introduction to matplotlib
Piyush rai
 
Event handling
Event handling
swapnac12
 
String and string buffer
String and string buffer
kamal kotecha
 
Method overriding
Method overriding
Azaz Maverick
 
Multithreading in java
Multithreading in java
Lovely Professional University
 
Packages in java
Packages in java
Kavitha713564
 
C++ Memory Management
C++ Memory Management
Rahul Jamwal
 
Java Threads
Java Threads
M Vishnuvardhan Reddy
 
Java Method, Static Block
Java Method, Static Block
Infoviaan Technologies
 
Java Strings
Java Strings
RaBiya Chaudhry
 
Java exception handling
Java exception handling
BHUVIJAYAVELU
 
Applet-Presentation-object-oriented-programming.pptx
Applet-Presentation-object-oriented-programming.pptx
cibec63256
 
Java: Java Applets
Java: Java Applets
Tareq Hasan
 

More Related Content

What's hot (20)

Java string handling
Java string handling
Salman Khan
 
java interface and packages
java interface and packages
VINOTH R
 
Multithreading in java
Multithreading in java
Arafat Hossan
 
Files in java
Files in java
Muthukumaran Subramanian
 
Threads concept in java
Threads concept in java
Muthukumaran Subramanian
 
Java Networking
Java Networking
Sunil OS
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVA
VINOTH R
 
Multithreading in java
Multithreading in java
Monika Mishra
 
Event Handling in java
Event Handling in java
Google
 
Introduction to matplotlib
Introduction to matplotlib
Piyush rai
 
Event handling
Event handling
swapnac12
 
String and string buffer
String and string buffer
kamal kotecha
 
Method overriding
Method overriding
Azaz Maverick
 
Multithreading in java
Multithreading in java
Lovely Professional University
 
Packages in java
Packages in java
Kavitha713564
 
C++ Memory Management
C++ Memory Management
Rahul Jamwal
 
Java Threads
Java Threads
M Vishnuvardhan Reddy
 
Java Method, Static Block
Java Method, Static Block
Infoviaan Technologies
 
Java Strings
Java Strings
RaBiya Chaudhry
 
Java exception handling
Java exception handling
BHUVIJAYAVELU
 

Similar to Java applet - java (20)

Applet-Presentation-object-oriented-programming.pptx
Applet-Presentation-object-oriented-programming.pptx
cibec63256
 
Java: Java Applets
Java: Java Applets
Tareq Hasan
 
Java Applet presentation............pptx
Java Applet presentation............pptx
ZaildarHussainFaisal
 
Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01
Abhishek Khune
 
Applet in java new
Applet in java new
Kavitha713564
 
Applets
Applets
Nuha Noor
 
oops with java modules iii & iv.pptx
oops with java modules iii & iv.pptx
rani marri
 
Lecture 22
Lecture 22
Debasish Pratihari
 
Applet progming
Applet progming
VIKRANTHMALLIKARJUN
 
Applets(1)cusdhsiohisdhfshihfsihfohf.ppt
Applets(1)cusdhsiohisdhfshihfsihfohf.ppt
Vijay Bhaskar Thatty
 
Appletsbjhbjiibibibikbibibjibjbibbjb.ppt
Appletsbjhbjiibibibikbibibjibjbibbjb.ppt
Vijay Bhaskar Thatty
 
Jsp applet
Jsp applet
Sanoj Kumar
 
L18 applets
L18 applets
teach4uin
 
Applets
Applets
Inayat Sharma
 
Applets
Applets
Abhishek Khune
 
Unit 7 Java
Unit 7 Java
arnold 7490
 
Java Apple dndkorksnsbsjdkkdjejdjrdndjdj
Java Apple dndkorksnsbsjdkkdjejdjrdndjdj
midhunmsd143
 
27 applet programming
27 applet programming
Ravindra Rathore
 
Appletjava
Appletjava
DEEPIKA T
 
Java applet
Java applet
GaneshKumarKanthiah
 
Applet-Presentation-object-oriented-programming.pptx
Applet-Presentation-object-oriented-programming.pptx
cibec63256
 
Java: Java Applets
Java: Java Applets
Tareq Hasan
 
Java Applet presentation............pptx
Java Applet presentation............pptx
ZaildarHussainFaisal
 
Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01
Abhishek Khune
 
oops with java modules iii & iv.pptx
oops with java modules iii & iv.pptx
rani marri
 
Applets(1)cusdhsiohisdhfshihfsihfohf.ppt
Applets(1)cusdhsiohisdhfshihfsihfohf.ppt
Vijay Bhaskar Thatty
 
Appletsbjhbjiibibibikbibibjibjbibbjb.ppt
Appletsbjhbjiibibibikbibibjibjbibbjb.ppt
Vijay Bhaskar Thatty
 
Java Apple dndkorksnsbsjdkkdjejdjrdndjdj
Java Apple dndkorksnsbsjdkkdjejdjrdndjdj
midhunmsd143
 
Ad

Recently uploaded (20)

Complete University of Calculus :: 2nd edition
Complete University of Calculus :: 2nd edition
Shabista Imam
 
How to Un-Obsolete Your Legacy Keypad Design
How to Un-Obsolete Your Legacy Keypad Design
Epec Engineered Technologies
 
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Mark Billinghurst
 
Solar thermal – Flat plate and concentrating collectors .pptx
Solar thermal – Flat plate and concentrating collectors .pptx
jdaniabraham1
 
Cadastral Maps
Cadastral Maps
Google
 
Call For Papers - 17th International Conference on Wireless & Mobile Networks...
Call For Papers - 17th International Conference on Wireless & Mobile Networks...
hosseinihamid192023
 
Machine Learning - Classification Algorithms
Machine Learning - Classification Algorithms
resming1
 
Tesla-Stock-Analysis-and-Forecast.pptx (1).pptx
Tesla-Stock-Analysis-and-Forecast.pptx (1).pptx
moonsony54
 
May 2025: Top 10 Read Articles in Data Mining & Knowledge Management Process
May 2025: Top 10 Read Articles in Data Mining & Knowledge Management Process
IJDKP
 
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
resming1
 
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
rr22001247
 
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Shabista Imam
 
Proposal for folders structure division in projects.pdf
Proposal for folders structure division in projects.pdf
Mohamed Ahmed
 
Fatality due to Falls at Working at Height
Fatality due to Falls at Working at Height
ssuserb8994f
 
Rapid Prototyping for XR: Lecture 2 - Low Fidelity Prototyping.
Rapid Prototyping for XR: Lecture 2 - Low Fidelity Prototyping.
Mark Billinghurst
 
Microwatt: Open Tiny Core, Big Possibilities
Microwatt: Open Tiny Core, Big Possibilities
IBM
 
60 Years and Beyond eBook 1234567891.pdf
60 Years and Beyond eBook 1234567891.pdf
waseemalazzeh
 
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Mark Billinghurst
 
DESIGN OF REINFORCED CONCRETE ELEMENTS S
DESIGN OF REINFORCED CONCRETE ELEMENTS S
prabhusp8
 
Industrial internet of things IOT Week-3.pptx
Industrial internet of things IOT Week-3.pptx
KNaveenKumarECE
 
Complete University of Calculus :: 2nd edition
Complete University of Calculus :: 2nd edition
Shabista Imam
 
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Mark Billinghurst
 
Solar thermal – Flat plate and concentrating collectors .pptx
Solar thermal – Flat plate and concentrating collectors .pptx
jdaniabraham1
 
Cadastral Maps
Cadastral Maps
Google
 
Call For Papers - 17th International Conference on Wireless & Mobile Networks...
Call For Papers - 17th International Conference on Wireless & Mobile Networks...
hosseinihamid192023
 
Machine Learning - Classification Algorithms
Machine Learning - Classification Algorithms
resming1
 
Tesla-Stock-Analysis-and-Forecast.pptx (1).pptx
Tesla-Stock-Analysis-and-Forecast.pptx (1).pptx
moonsony54
 
May 2025: Top 10 Read Articles in Data Mining & Knowledge Management Process
May 2025: Top 10 Read Articles in Data Mining & Knowledge Management Process
IJDKP
 
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
resming1
 
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
rr22001247
 
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Abraham Silberschatz-Operating System Concepts (9th,2012.12).pdf
Shabista Imam
 
Proposal for folders structure division in projects.pdf
Proposal for folders structure division in projects.pdf
Mohamed Ahmed
 
Fatality due to Falls at Working at Height
Fatality due to Falls at Working at Height
ssuserb8994f
 
Rapid Prototyping for XR: Lecture 2 - Low Fidelity Prototyping.
Rapid Prototyping for XR: Lecture 2 - Low Fidelity Prototyping.
Mark Billinghurst
 
Microwatt: Open Tiny Core, Big Possibilities
Microwatt: Open Tiny Core, Big Possibilities
IBM
 
60 Years and Beyond eBook 1234567891.pdf
60 Years and Beyond eBook 1234567891.pdf
waseemalazzeh
 
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Mark Billinghurst
 
DESIGN OF REINFORCED CONCRETE ELEMENTS S
DESIGN OF REINFORCED CONCRETE ELEMENTS S
prabhusp8
 
Industrial internet of things IOT Week-3.pptx
Industrial internet of things IOT Week-3.pptx
KNaveenKumarECE
 
Ad

Java applet - java

  • 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); } }
  • 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