SlideShare a Scribd company logo
APPLETS
Mr.V.M.Prabhakaran, AP,
Department of CSE
KIT-Kalaignarkarunanidhi Institute of Technology
INTRODUCTION
• Applet is a small program
– can be placed on a web page
– will be executed by the web browser
– give web pages “dynamic content”
– Applet class is one of the AWT components
• Java applets are usually graphical
– Draw graphics in a defined screen area
– Enable user interaction with GUI elements
TYPES OF APPLET
1. LOCALAPPLET
 Developed and Stored in a local system
 No net connection needed
 It will search the directories in the local system and
locates and loads the specified applet.
2. REMOTE APPLET
 Developed by some one
 Stored on a remote computer connected to the
internet
 Download the remote applet into our system
 To download we must need to know the URL
CONTRAST APPLICATION WITH
APPLET
APPLICATION APPLET
•Object class extended
•Class not declared public
•Has a main()
•static keyword used
•Uses System.exit(1)
•JApplet class extended
•class declared to be public
•init() instead of main()
•init() not declared with static
keyword
4
ADVANTAGES AND DISADVANTAGES OF
APPLET
Advantages
• 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.
Disadvantages
• Plugin is required at client browser to execute
applet.
HIERARCHY OF APPLET
PREPARING TO WRITE APPLET
Understand
– When to use
– How it works
– Features of it
– Where to start
STEPS IN DEVELOPMENT OF
APPLET
1. Build an applet code (.java)
2. Create an executable applet (.class)
3. Desigining a web page using HTML tags
4. Prepare <APPLET> Tag
5. Incorporate <APPLET> Tag into web page
6. Create HTML file
7. Test the Applet
LIFECYCLE OF JAVAAPPLET
• Applet is initialized.
• Applet is started.
• Applet is painted.
• Applet is stopped.
• Applet is destroyed.
Methods are called in this order
• init and destroy are only
called once each
• start and stop are called
whenever the browser enters
and leaves the page
• do some work is code called
by your listeners
• paint is called when the
applet needs to be repainted
init()
start()
stop()
destroy()
do some work
APPLET METHODS
public void init ()
public void start ()
public void stop ()
public void destroy ()
public void paint (Graphics)
Also:
public void repaint()
public void update (Graphics)
public void showStatus(String)
public String getParameter(String)
LIFECYCLE METHODS FOR APPLET:
java.applet.Applet class
It provides 4 life cycle methods of 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.
java.awt.Component class
• 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.
public void init ( )
• This is the first method to execute
• It is an ideal place to initialize variables
• It is the best place to define the GUI
Components (buttons, text fields, scrollbars,
etc.), lay them out, and add listeners to them
• Almost every applet you ever write will have
an init( ) method
public void start ( )
• Not always needed
• Called after init( )
• Called each time the page is loaded and
restarted
• Used mostly in conjunction with stop( )
• start() and stop( ) are used when the Applet is
doing time-consuming calculations that you
don’t want to continue when the page is not in
front
public void stop( )
• Not always needed
• Called when the browser leaves the page
• Called just before destroy( )
• Use stop( ) if the applet is doing heavy
computation that you don’t want to continue
when the browser is on some other page
• Used mostly in conjunction with start()
public void destroy( )
• Rarely needed
• Called after stop( )
• Use to explicitly release system resources (like
threads)
• System resources are usually released
automatically
SAMPLE GRAPHICS METHODS
• A Graphics is something you can paint on
g.drawRect(x, y, width, height);
g.fillRect(x, y, width, height);
g.drawOval(x, y, width, height);
g.fillOval(x, y, width, height);
g.setColor(Color.red);
g.drawString(“Hello”, 20, 20); Hello
STRUCTURE OF AN HTML PAGE
• Most HTML
tags are
containers.
• A container is
<tag> to
</tag>
HTML
TITLE
BODYHEAD
(content)
APPLETS AND WEB PAGES – HTML
• Create the web page
code using a text
editor
• Save it with an .html
suffix
• Open this file with
appletviewer or with
a web browser that
supports Java
• Java Plug-in must be
installed (part of
J2SDK 1.4.1 from
Sun)
19
<HTML>
<HEAD>
</HEAD>
<BODY>
<APPLET CODE = . . . >
</APPLET>
</BODY>
</HTML>
SYNTAX
import java.applet.Applet;
import java.awt.Graphics;
……
…….
pub.lic class Appletname extends Applet
{
…..
……
public void paint(Graphics g)
{ ….
….
}
SIMPLE EXAMPLE OF APPLET
To execute the applet by html file, create
an applet and compile it. After that create
an html file and place the applet code in
html file. Now click the html file.
//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);
}
}
//myapplet.html
<html>
<body>
<applet code="First.class" width="300" h
eight="300">
</applet>
</body>
</html>
EXECUTING AND RUNNING AN
APPLET
There are two ways to run an applet
• By html file.
• By appletViewer tool (for testing purpose).
Execute the applet by appletviewer tool, write in
command prompt:
• c:>javac First.java
• c:>appletviewer First.java
SIMPLIFIED PROGRAM
import java.applet.Applet;
import java.awt.Graphics;
/*<applet code="First.class" width="300" height="300">
</applet>*/
public class First extends Applet{
public void paint(Graphics g){
g.drawString(“Welcome to Java Programming!",150,150);
}
}
APPLICATIONS
• QuickTime movies
• Flash movies
• Windows Media Player
• 3D modeling
• Browser games

More Related Content

What's hot

Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
Shraddha
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
Nilesh Dalvi
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
kamal kotecha
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handling
Nahian Ahmed
 
Threads concept in java
Threads concept in javaThreads concept in java
Threads concept in java
Muthukumaran Subramanian
 
Interface
InterfaceInterface
Interface
kamal kotecha
 
Java threads
Java threadsJava threads
Java threads
Prabhakaran V M
 
Java string handling
Java string handlingJava string handling
Java string handling
Salman Khan
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
Naz Abdalla
 
Exception Handling in JAVA
Exception Handling in JAVAException Handling in JAVA
Exception Handling in JAVA
SURIT DATTA
 
Data Types & Variables in JAVA
Data Types & Variables in JAVAData Types & Variables in JAVA
Data Types & Variables in JAVA
Ankita Totala
 
input/ output in java
input/ output  in javainput/ output  in java
input/ output in java
sharma230399
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
Vikas Jagtap
 
Java Streams
Java StreamsJava Streams
Java Streams
M Vishnuvardhan Reddy
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
Google
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
Monika Mishra
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
lalithambiga kamaraj
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
Pooja Jaiswal
 

What's hot (20)

Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handling
 
Threads concept in java
Threads concept in javaThreads concept in java
Threads concept in java
 
Interface
InterfaceInterface
Interface
 
Java threads
Java threadsJava threads
Java threads
 
Java string handling
Java string handlingJava string handling
Java string handling
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Exception Handling in JAVA
Exception Handling in JAVAException Handling in JAVA
Exception Handling in JAVA
 
Data Types & Variables in JAVA
Data Types & Variables in JAVAData Types & Variables in JAVA
Data Types & Variables in JAVA
 
input/ output in java
input/ output  in javainput/ output  in java
input/ output in java
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
 
Java Streams
Java StreamsJava Streams
Java Streams
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 

Similar to Applets

Applets
AppletsApplets
Applets
Inayat Sharma
 
Applet
AppletApplet
Applets
AppletsApplets
Applets
Nuha Noor
 
Applets
AppletsApplets
Applets
Rishav Upreti
 
6.applet programming in java
6.applet programming in java6.applet programming in java
6.applet programming in javaDeepak Sharma
 
Applet intro
Applet introApplet intro
Applet intro
Nitin Birari
 
Java applet
Java appletJava applet
Java applet
Rohan Gajre
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
mcanotes
 
java Applet Introduction
java Applet Introductionjava Applet Introduction
java Applet Introduction
yugandhar vadlamudi
 
applet.pptx
applet.pptxapplet.pptx
applet.pptx
SachinBhosale73
 
L18 applets
L18 appletsL18 applets
L18 applets
teach4uin
 
6applets And Graphics
6applets And Graphics6applets And Graphics
6applets And GraphicsAdil Jafri
 
java applets
java appletsjava applets
java applets
Waheed Warraich
 
Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01Abhishek Khune
 
Advanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.pptAdvanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.ppt
miki304759
 
Applet.pptx
Applet.pptxApplet.pptx
Applet.pptx
LakachewYezihalem
 
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
 
Applets 101-fa06
Applets 101-fa06Applets 101-fa06
Applets 101-fa06nrayan
 

Similar to Applets (20)

Applets
AppletsApplets
Applets
 
Applets
AppletsApplets
Applets
 
27 applet programming
27  applet programming27  applet programming
27 applet programming
 
Applet
AppletApplet
Applet
 
Applets
AppletsApplets
Applets
 
Applets
AppletsApplets
Applets
 
6.applet programming in java
6.applet programming in java6.applet programming in java
6.applet programming in java
 
Applet intro
Applet introApplet intro
Applet intro
 
Java applet
Java appletJava applet
Java applet
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
 
java Applet Introduction
java Applet Introductionjava Applet Introduction
java Applet Introduction
 
applet.pptx
applet.pptxapplet.pptx
applet.pptx
 
L18 applets
L18 appletsL18 applets
L18 applets
 
6applets And Graphics
6applets And Graphics6applets And Graphics
6applets And Graphics
 
java applets
java appletsjava applets
java applets
 
Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01
 
Advanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.pptAdvanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.ppt
 
Applet.pptx
Applet.pptxApplet.pptx
Applet.pptx
 
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
 
Applets 101-fa06
Applets 101-fa06Applets 101-fa06
Applets 101-fa06
 

More from Prabhakaran V M

Strings in python
Strings in pythonStrings in python
Strings in python
Prabhakaran V M
 
Operators in python
Operators in pythonOperators in python
Operators in python
Prabhakaran V M
 
Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solving
Prabhakaran V M
 
Open mp directives
Open mp directivesOpen mp directives
Open mp directives
Prabhakaran V M
 
Xml schema
Xml schemaXml schema
Xml schema
Prabhakaran V M
 
Html 5
Html 5Html 5
Introduction to Multi-core Architectures
Introduction to Multi-core ArchitecturesIntroduction to Multi-core Architectures
Introduction to Multi-core Architectures
Prabhakaran V M
 

More from Prabhakaran V M (7)

Strings in python
Strings in pythonStrings in python
Strings in python
 
Operators in python
Operators in pythonOperators in python
Operators in python
 
Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solving
 
Open mp directives
Open mp directivesOpen mp directives
Open mp directives
 
Xml schema
Xml schemaXml schema
Xml schema
 
Html 5
Html 5Html 5
Html 5
 
Introduction to Multi-core Architectures
Introduction to Multi-core ArchitecturesIntroduction to Multi-core Architectures
Introduction to Multi-core Architectures
 

Recently uploaded

Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Yara Milbes
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
QuickwayInfoSystems3
 

Recently uploaded (20)

Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
 

Applets

  • 1. APPLETS Mr.V.M.Prabhakaran, AP, Department of CSE KIT-Kalaignarkarunanidhi Institute of Technology
  • 2. INTRODUCTION • Applet is a small program – can be placed on a web page – will be executed by the web browser – give web pages “dynamic content” – Applet class is one of the AWT components • Java applets are usually graphical – Draw graphics in a defined screen area – Enable user interaction with GUI elements
  • 3. TYPES OF APPLET 1. LOCALAPPLET  Developed and Stored in a local system  No net connection needed  It will search the directories in the local system and locates and loads the specified applet. 2. REMOTE APPLET  Developed by some one  Stored on a remote computer connected to the internet  Download the remote applet into our system  To download we must need to know the URL
  • 4. CONTRAST APPLICATION WITH APPLET APPLICATION APPLET •Object class extended •Class not declared public •Has a main() •static keyword used •Uses System.exit(1) •JApplet class extended •class declared to be public •init() instead of main() •init() not declared with static keyword 4
  • 5. ADVANTAGES AND DISADVANTAGES OF APPLET Advantages • 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. Disadvantages • Plugin is required at client browser to execute applet.
  • 7. PREPARING TO WRITE APPLET Understand – When to use – How it works – Features of it – Where to start
  • 8. STEPS IN DEVELOPMENT OF APPLET 1. Build an applet code (.java) 2. Create an executable applet (.class) 3. Desigining a web page using HTML tags 4. Prepare <APPLET> Tag 5. Incorporate <APPLET> Tag into web page 6. Create HTML file 7. Test the Applet
  • 9. LIFECYCLE OF JAVAAPPLET • Applet is initialized. • Applet is started. • Applet is painted. • Applet is stopped. • Applet is destroyed.
  • 10. Methods are called in this order • init and destroy are only called once each • start and stop are called whenever the browser enters and leaves the page • do some work is code called by your listeners • paint is called when the applet needs to be repainted init() start() stop() destroy() do some work
  • 11. APPLET METHODS public void init () public void start () public void stop () public void destroy () public void paint (Graphics) Also: public void repaint() public void update (Graphics) public void showStatus(String) public String getParameter(String)
  • 12. LIFECYCLE METHODS FOR APPLET: java.applet.Applet class It provides 4 life cycle methods of 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. java.awt.Component class • 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.
  • 13. public void init ( ) • This is the first method to execute • It is an ideal place to initialize variables • It is the best place to define the GUI Components (buttons, text fields, scrollbars, etc.), lay them out, and add listeners to them • Almost every applet you ever write will have an init( ) method
  • 14. public void start ( ) • Not always needed • Called after init( ) • Called each time the page is loaded and restarted • Used mostly in conjunction with stop( ) • start() and stop( ) are used when the Applet is doing time-consuming calculations that you don’t want to continue when the page is not in front
  • 15. public void stop( ) • Not always needed • Called when the browser leaves the page • Called just before destroy( ) • Use stop( ) if the applet is doing heavy computation that you don’t want to continue when the browser is on some other page • Used mostly in conjunction with start()
  • 16. public void destroy( ) • Rarely needed • Called after stop( ) • Use to explicitly release system resources (like threads) • System resources are usually released automatically
  • 17. SAMPLE GRAPHICS METHODS • A Graphics is something you can paint on g.drawRect(x, y, width, height); g.fillRect(x, y, width, height); g.drawOval(x, y, width, height); g.fillOval(x, y, width, height); g.setColor(Color.red); g.drawString(“Hello”, 20, 20); Hello
  • 18. STRUCTURE OF AN HTML PAGE • Most HTML tags are containers. • A container is <tag> to </tag> HTML TITLE BODYHEAD (content)
  • 19. APPLETS AND WEB PAGES – HTML • Create the web page code using a text editor • Save it with an .html suffix • Open this file with appletviewer or with a web browser that supports Java • Java Plug-in must be installed (part of J2SDK 1.4.1 from Sun) 19 <HTML> <HEAD> </HEAD> <BODY> <APPLET CODE = . . . > </APPLET> </BODY> </HTML>
  • 20. SYNTAX import java.applet.Applet; import java.awt.Graphics; …… ……. pub.lic class Appletname extends Applet { ….. …… public void paint(Graphics g) { …. …. }
  • 21. SIMPLE EXAMPLE OF APPLET To execute the applet by html file, create an applet and compile it. After that create an html file and place the applet code in html file. Now click the html file. //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); } } //myapplet.html <html> <body> <applet code="First.class" width="300" h eight="300"> </applet> </body> </html>
  • 22. EXECUTING AND RUNNING AN APPLET There are two ways to run an applet • By html file. • By appletViewer tool (for testing purpose). Execute the applet by appletviewer tool, write in command prompt: • c:>javac First.java • c:>appletviewer First.java
  • 23. SIMPLIFIED PROGRAM import java.applet.Applet; import java.awt.Graphics; /*<applet code="First.class" width="300" height="300"> </applet>*/ public class First extends Applet{ public void paint(Graphics g){ g.drawString(“Welcome to Java Programming!",150,150); } }
  • 24.
  • 25. APPLICATIONS • QuickTime movies • Flash movies • Windows Media Player • 3D modeling • Browser games