SlideShare a Scribd company logo
Java Applets
By – NiTiN BiRaRi
Applet Programming
• local and remote applets
• difference between applet and application
• applet life cycle
• developing executable applet code
Applet Introduction
• Applets are small Java programs that are used
in Internet computing
• Applets,
– Transported over the Internet
– Automatically installed in client machine
– Run as part of a web document
– Applets can be run using a tool ‘appletviewer’
• Applets interact with the user through the
AWT, not through the console-based I/O
classes
• Browser runs applet in a Java Virtual Machine
(JVM)
local and remote applets
• Applets can be classified into two types…
– Local applets
– Remote applets
• Local applet
– Developed and stored in local system
– No need for internet connection for the local
system
– Local directories were searched to locate the
specified applet
• Remote applet
– Developed by someone else
– Stored on a remote computer connected to the
internet
– Our system needs an internet connection
– The applet is downloaded into our local system via
internet
– Run it on our system
• 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.
developing executable applet code
• Let’s begin with the simple applet shown here:
import java.awt.*;
import java.applet.*;
public class SimpleApplet extends Applet {
public void paint(Graphics g) {
g.drawString("A Simple Applet", 20, 20);
}
}
• compile in the same way
• there are two ways in which you can run an
applet:
– Executing the applet within a Java-compatible web
browser.
– Using an applet viewer
HTML APPLET Tag
• CODEBASE is an optional attribute that
specifies the base URL of the applet code
• CODE is a required attribute that gives the
name of the file containing your applet’s
compiled .class file
• ALT tag is an optional attribute used to specify
a short text message that should be displayed
if the browser recognizes the APPLET tag but
can’t currently run Java applets
• NAME is an optional attribute used to specify
a name for the applet instance
• WIDTH and HEIGHT are required attributes
that give the size (in pixels) of the applet
display area
• ALIGN is an optional attribute that specifies
the alignment of the applet
• VSPACE specifies the space, in pixels, above
and below the applet
• HSPACE specifies the space, in pixels, on each
side of the applet
• PARAM tag allows you to specify applet-
specific arguments
• Some Points About Applets…
– Applets are event driven
– Applets do not use main() method
– They run in a browser
– They cannot read or write the files from the local
system
– Applets cannot run any other program from the
local computer
Applet class methods
• destroy()
Called by the browser or applet viewer to inform this applet that it is
being reclaimed and that it should destroy any resources that it has allocated.
• getAppletContext()
Determines this applet's context, which allows the applet to query
and affect the environment in which it runs.
• getAppletInfo()
Returns information about this applet.
• getAudioClip(URL)
Returns the AudioClip object specified by the URL argument.
• getAudioClip(URL, String)
Returns the AudioClip object specified by the URL and name
arguments.
• getCodeBase()
Gets the base URL.
• getDocumentBase()
Gets the document URL.
• getImage(URL)
Returns an Image object that can then be painted on the
screen.
• getImage(URL, String)
Returns an Image object that can then be painted on the
screen.
• getLocale()
Gets the Locale for the applet, if it has been set.
• getParameter(String)
Returns the value of the named parameter in the HTML tag.
• getParameterInfo()
Returns information about the parameters than are
understood by this applet.
• init()
Called by the browser or applet viewer to inform this applet
that it has been loaded into the system.
• isActive()
Determines if this applet is active.
• play(URL)
Plays the audio clip at the specified absolute URL.
• play(URL, String)
Plays the audio clip given the URL and a specifier that is
relative to it.
• resize(Dimension)
Requests that this applet be resized.
• resize(int, int)
Requests that this applet be resized.
• setStub(AppletStub)
Sets this applet's stub.
• showStatus(String)
Requests that the argument string be displayed in the "status
window".
• start()
Called by the browser or applet viewer to inform this applet that it
should start its execution.
• stop()
Called by the browser or applet viewer to inform this applet that it
should stop its execution.
Component class method
• void setBackground(Color newColor)
• void setForeground(Color newColor)
• Color getBackground( )
• Color getForeground( )
Can you?
• Explain concept of applet life cycle.
• Differentiate applet and application.
• Develop code for simple Java applets.
• Explain applet tag and its parameter.
• Use the methods of the applet and
component classes required for a basic applet.

More Related Content

What's hot

Operators in java
Operators in javaOperators in java
Operators in java
AbhishekMondal42
 
This keyword in java
This keyword in javaThis keyword in java
This keyword in java
Hitesh Kumar
 
HTTP Request and Response Structure
HTTP Request and Response StructureHTTP Request and Response Structure
HTTP Request and Response Structure
BhagyashreeGajera1
 
Java EE 7 introduction
Java EE 7  introductionJava EE 7  introduction
Java EE 7 introduction
Moumie Soulemane
 
Exception Handling in JAVA
Exception Handling in JAVAException Handling in JAVA
Exception Handling in JAVA
SURIT DATTA
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
Tushar B Kute
 
Registers and-common-bus
Registers and-common-busRegisters and-common-bus
Registers and-common-busAnuj Modi
 
I/O Streams
I/O StreamsI/O Streams
I/O Streams
Ravi Chythanya
 
Basics of boot-loader
Basics of boot-loaderBasics of boot-loader
Basics of boot-loader
iamumr
 
OOP with Java - Continued
OOP with Java - Continued OOP with Java - Continued
OOP with Java - Continued
Hitesh-Java
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
Dhruvin Nakrani
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
Raja Sekhar
 
U boot-boot-flow
U boot-boot-flowU boot-boot-flow
Java applet
Java appletJava applet
Java applet
Rohan Gajre
 
Final keyword in java
Final keyword in javaFinal keyword in java
Final keyword in java
Lovely Professional University
 
HTTP Basics
HTTP BasicsHTTP Basics
HTTP Basics
sanjoysanyal
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Tushar B Kute
 

What's hot (20)

Java interface
Java interfaceJava interface
Java interface
 
Operators in java
Operators in javaOperators in java
Operators in java
 
This keyword in java
This keyword in javaThis keyword in java
This keyword in java
 
HTTP Request and Response Structure
HTTP Request and Response StructureHTTP Request and Response Structure
HTTP Request and Response Structure
 
Java EE 7 introduction
Java EE 7  introductionJava EE 7  introduction
Java EE 7 introduction
 
Oops concept on c#
Oops concept on c#Oops concept on c#
Oops concept on c#
 
Exception Handling in JAVA
Exception Handling in JAVAException Handling in JAVA
Exception Handling in JAVA
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
Registers and-common-bus
Registers and-common-busRegisters and-common-bus
Registers and-common-bus
 
I/O Streams
I/O StreamsI/O Streams
I/O Streams
 
Basics of boot-loader
Basics of boot-loaderBasics of boot-loader
Basics of boot-loader
 
OOP with Java - Continued
OOP with Java - Continued OOP with Java - Continued
OOP with Java - Continued
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
U boot-boot-flow
U boot-boot-flowU boot-boot-flow
U boot-boot-flow
 
Java applet
Java appletJava applet
Java applet
 
Final keyword in java
Final keyword in javaFinal keyword in java
Final keyword in java
 
HTTP Basics
HTTP BasicsHTTP Basics
HTTP Basics
 
PHP slides
PHP slidesPHP slides
PHP slides
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 

Viewers also liked

21servers And Applets
21servers And Applets21servers And Applets
21servers And AppletsAdil Jafri
 
Java Servlet
Java Servlet Java Servlet
Java Servlet
Rajiv Gupta
 
Applet Vs Servlet
Applet Vs ServletApplet Vs Servlet
Applet Vs Servlet
Bharat Sahu
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technology
Tanmoy Barman
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - Components
Kaml Sah
 
Java Applet
Java AppletJava Applet
Applet life cycle
Applet life cycleApplet life cycle
Applet life cyclemyrajendra
 

Viewers also liked (8)

Asif
AsifAsif
Asif
 
21servers And Applets
21servers And Applets21servers And Applets
21servers And Applets
 
Java Servlet
Java Servlet Java Servlet
Java Servlet
 
Applet Vs Servlet
Applet Vs ServletApplet Vs Servlet
Applet Vs Servlet
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technology
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - Components
 
Java Applet
Java AppletJava Applet
Java Applet
 
Applet life cycle
Applet life cycleApplet life cycle
Applet life cycle
 

Similar to Applet intro

Java applet
Java appletJava applet
Java applet
GaneshKumarKanthiah
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
mcanotes
 
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.pptx
applet.pptxapplet.pptx
applet.pptx
SachinBhosale73
 
Applets
AppletsApplets
Applets
Nuha Noor
 
6applets And Graphics
6applets And Graphics6applets And Graphics
6applets And GraphicsAdil Jafri
 
Applets
AppletsApplets
Java applet basics
Java applet basicsJava applet basics
Java applet basicsSunil Pandey
 
Applet.pptx
Applet.pptxApplet.pptx
Applet.pptx
LakachewYezihalem
 
Java files and io streams
Java files and io streamsJava files and io streams
Java files and io streams
RubaNagarajan
 
Advanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.pptAdvanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.ppt
miki304759
 
Java applet-basics
Java applet-basicsJava applet-basics
Java applet-basics
kanchanmahajan23
 
Applet (1)
Applet (1)Applet (1)
Applet (1)
DEEPIKA T
 
Java applet
Java appletJava applet
Java applet
Elizabeth alexander
 
Java applet-basics
Java applet-basicsJava applet-basics
Java applet-basics
kanchanmahajan23
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
Nexus
 
Java programming basics notes for beginners(java programming tutorials)
Java programming basics notes for beginners(java programming tutorials)Java programming basics notes for beginners(java programming tutorials)
Java programming basics notes for beginners(java programming tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
java programming - applets
java programming - appletsjava programming - applets
java programming - applets
HarshithaAllu
 

Similar to Applet intro (20)

Java applet
Java appletJava applet
Java applet
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
 
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.pptx
applet.pptxapplet.pptx
applet.pptx
 
Applets
AppletsApplets
Applets
 
27 applet programming
27  applet programming27  applet programming
27 applet programming
 
6applets And Graphics
6applets And Graphics6applets And Graphics
6applets And Graphics
 
Applets
AppletsApplets
Applets
 
Java applet basics
Java applet basicsJava applet basics
Java applet basics
 
Applet.pptx
Applet.pptxApplet.pptx
Applet.pptx
 
Java files and io streams
Java files and io streamsJava files and io streams
Java files and io streams
 
Advanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.pptAdvanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.ppt
 
Java applet-basics
Java applet-basicsJava applet-basics
Java applet-basics
 
Applet (1)
Applet (1)Applet (1)
Applet (1)
 
Java applet
Java appletJava applet
Java applet
 
Java applet-basics
Java applet-basicsJava applet-basics
Java applet-basics
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
Java programming basics notes for beginners(java programming tutorials)
Java programming basics notes for beginners(java programming tutorials)Java programming basics notes for beginners(java programming tutorials)
Java programming basics notes for beginners(java programming tutorials)
 
java programming - applets
java programming - appletsjava programming - applets
java programming - applets
 

Recently uploaded

Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 

Recently uploaded (20)

Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 

Applet intro

  • 1. Java Applets By – NiTiN BiRaRi
  • 2. Applet Programming • local and remote applets • difference between applet and application • applet life cycle • developing executable applet code
  • 3. Applet Introduction • Applets are small Java programs that are used in Internet computing • Applets, – Transported over the Internet – Automatically installed in client machine – Run as part of a web document – Applets can be run using a tool ‘appletviewer’
  • 4. • Applets interact with the user through the AWT, not through the console-based I/O classes • Browser runs applet in a Java Virtual Machine (JVM)
  • 5. local and remote applets • Applets can be classified into two types… – Local applets – Remote applets • Local applet – Developed and stored in local system – No need for internet connection for the local system – Local directories were searched to locate the specified applet
  • 6. • Remote applet – Developed by someone else – Stored on a remote computer connected to the internet – Our system needs an internet connection – The applet is downloaded into our local system via internet – Run it on our system
  • 7.
  • 8. • 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.
  • 9. • 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.
  • 10. • 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.
  • 11. developing executable applet code • Let’s begin with the simple applet shown here: import java.awt.*; import java.applet.*; public class SimpleApplet extends Applet { public void paint(Graphics g) { g.drawString("A Simple Applet", 20, 20); } }
  • 12. • compile in the same way • there are two ways in which you can run an applet: – Executing the applet within a Java-compatible web browser. – Using an applet viewer
  • 14. • CODEBASE is an optional attribute that specifies the base URL of the applet code • CODE is a required attribute that gives the name of the file containing your applet’s compiled .class file • ALT tag is an optional attribute used to specify a short text message that should be displayed if the browser recognizes the APPLET tag but can’t currently run Java applets
  • 15. • NAME is an optional attribute used to specify a name for the applet instance • WIDTH and HEIGHT are required attributes that give the size (in pixels) of the applet display area • ALIGN is an optional attribute that specifies the alignment of the applet • VSPACE specifies the space, in pixels, above and below the applet
  • 16. • HSPACE specifies the space, in pixels, on each side of the applet • PARAM tag allows you to specify applet- specific arguments
  • 17. • Some Points About Applets… – Applets are event driven – Applets do not use main() method – They run in a browser – They cannot read or write the files from the local system – Applets cannot run any other program from the local computer
  • 18. Applet class methods • destroy() Called by the browser or applet viewer to inform this applet that it is being reclaimed and that it should destroy any resources that it has allocated. • getAppletContext() Determines this applet's context, which allows the applet to query and affect the environment in which it runs. • getAppletInfo() Returns information about this applet. • getAudioClip(URL) Returns the AudioClip object specified by the URL argument. • getAudioClip(URL, String) Returns the AudioClip object specified by the URL and name arguments. • getCodeBase() Gets the base URL.
  • 19. • getDocumentBase() Gets the document URL. • getImage(URL) Returns an Image object that can then be painted on the screen. • getImage(URL, String) Returns an Image object that can then be painted on the screen. • getLocale() Gets the Locale for the applet, if it has been set. • getParameter(String) Returns the value of the named parameter in the HTML tag.
  • 20. • getParameterInfo() Returns information about the parameters than are understood by this applet. • init() Called by the browser or applet viewer to inform this applet that it has been loaded into the system. • isActive() Determines if this applet is active. • play(URL) Plays the audio clip at the specified absolute URL. • play(URL, String) Plays the audio clip given the URL and a specifier that is relative to it.
  • 21. • resize(Dimension) Requests that this applet be resized. • resize(int, int) Requests that this applet be resized. • setStub(AppletStub) Sets this applet's stub. • showStatus(String) Requests that the argument string be displayed in the "status window". • start() Called by the browser or applet viewer to inform this applet that it should start its execution. • stop() Called by the browser or applet viewer to inform this applet that it should stop its execution.
  • 22. Component class method • void setBackground(Color newColor) • void setForeground(Color newColor) • Color getBackground( ) • Color getForeground( )
  • 23. Can you? • Explain concept of applet life cycle. • Differentiate applet and application. • Develop code for simple Java applets. • Explain applet tag and its parameter. • Use the methods of the applet and component classes required for a basic applet.