SlideShare a Scribd company logo
APPLET
PROGRAMMING
2
Introduction
We can write two kinds of program in JAVA
they are
APPLICATION BASED
APPLET BASED
The application based programs are the
programs which are used in the places such
as super markets, hospitals etc.
The applet based program is used for the
development of Graphics .
APPLETS
APPLET is a small application
embedded in HTML page, which is
accessed & transported over the
Internet , automatically installed
into client machines and run as
part of web page.
Applet are great for creating
dynamic & interactive web
applications .
Applet is a self executing program .
Init() : initializes applet before loading.
Start(): starts execution of applet
Paint(): graphics created
Stop(): stops any operation
Destroy(): applet completes execution
To create applet , Applet class from java. applet
package should be imported so tht they are
automatically run by any applet program
Applet Life Cycle
ITFT- Applet in java
The init() method
 The init method is invoked after the
applet is created or recreated.
 A subclass of Applet should
overrides this method if the subclass
has an initialization to perform.
 Usually includes creating new
thread, loading images, setting up
GUI components
Start() method
 The start method is invoked after the init
method.
 Called whenever the applet become active
 A subclass of Applet overrides this method
if it has any operation that needs to be
performed whenever the webpage is
visited.
 An applet with animation might use the start
method to resume animation
Stop() method
 The stop method is the opposite of the start
method.
 Is invoked when the user leave the page.
 A subclass of Applet overrides this method
if it has any operation that needs to be
performed
 When the user leaves the page, any
threads that applet has started but not
completed will continue to run. You should
override the stop method to suspend the
running threads so that the applet does not
take up system resources when it is
inactive
Destroy() method
 The destroy() method is invoked when the
browser exits normally to inform the applet
that is no longer needed and should release
any resources it has allocated.
 The stop method is always called before the
destroy method
 A subclass of Applet overrides this method if
it has any operation that needs to be
performed before it is destroyed
 Usually you won’t need to override this
method unless you wish to release specific
resources, such as threads that the applet
created
A SIMPLE APPLET
import java.applet.*;
import java.awt.*;
public class MyApplet extends Applet
{
public void paint (Graphics g)
{
g.drawString ("Hi this is my first Applet
program", 25, 50);
}
}
11
Adding applet to Html File
• You can only run an applet in an HTML page
• The HTML looks something like this:
• <html>
<body>
<h1>Myapplet Applet</h1>
<applet code=“Myapplet.class"
width="250" height="200">
</applet>
</body>
</html>
Running Applet in
AppletViewer
• Compiling
javac Myapplet.java
• Running
appletviewer Myapplet.java
Applet viewer is a command line program to run Java
applets.
ITFT- Applet in java
Ad

More Related Content

What's hot (20)

Applet progming
Applet progmingApplet progming
Applet progming
VIKRANTHMALLIKARJUN
 
6.applet programming in java
6.applet programming in java6.applet programming in java
6.applet programming in java
Deepak Sharma
 
Java applet basics
Java applet basicsJava applet basics
Java applet basics
Sunil Pandey
 
Java applets
Java appletsJava applets
Java applets
M Vishnuvardhan Reddy
 
Appl clas nd architect.56
Appl clas nd architect.56Appl clas nd architect.56
Appl clas nd architect.56
myrajendra
 
Java applets
Java appletsJava applets
Java applets
Pihu Goel
 
Applet programming in java
Applet programming in javaApplet programming in java
Applet programming in java
Vidya Bharti
 
java Applet Introduction
java Applet Introductionjava Applet Introduction
java Applet Introduction
yugandhar vadlamudi
 
Applet init nd termination.59
Applet init nd termination.59Applet init nd termination.59
Applet init nd termination.59
myrajendra
 
Java applets
Java appletsJava applets
Java applets
lopjuan
 
Java Applet
Java AppletJava Applet
Java Applet
Athharul Haq
 
Java applets
Java appletsJava applets
Java applets
QUAID-E-AWAM UNIVERSITY OF ENGINEERING, SCIENCE & TECHNOLOGY, NAWABSHAH, SINDH, PAKISTAN
 
Applet programming
Applet programming Applet programming
Applet programming
Devyani Vaidya
 
java applets
java appletsjava applets
java applets
Waheed Warraich
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
RamaPrabha24
 
Applet execution
Applet execution Applet execution
Applet execution
myrajendra
 
Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
amitksaha
 
JAVA APPLETS
JAVA APPLETSJAVA APPLETS
JAVA APPLETS
Ramkrishna bhagat
 
Applet life cycle
Applet life cycleApplet life cycle
Applet life cycle
myrajendra
 
Applet in java
Applet in javaApplet in java
Applet in java
Jancypriya M
 

Viewers also liked (16)

Java: Java Applets
Java: Java AppletsJava: Java Applets
Java: Java Applets
Tareq Hasan
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
mcanotes
 
Javalecture 1
Javalecture 1Javalecture 1
Javalecture 1
mrinalbhutani
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC Structure
Dipika Wadhvani
 
Open and Close Door ppt
 Open and Close Door ppt Open and Close Door ppt
Open and Close Door ppt
Devyani Vaidya
 
L13 string handling(string class)
L13 string handling(string class)L13 string handling(string class)
L13 string handling(string class)
teach4uin
 
Latest seminar topics
Latest seminar topicsLatest seminar topics
Latest seminar topics
Pulla Surya
 
Java Programming- Introduction to Java Applet Programs
Java Programming- Introduction to Java Applet ProgramsJava Programming- Introduction to Java Applet Programs
Java Programming- Introduction to Java Applet Programs
Trinity Dwarka
 
String and string buffer
String and string bufferString and string buffer
String and string buffer
kamal kotecha
 
applet using java
applet using javaapplet using java
applet using java
Kartik Kalpande Patil
 
Java swing
Java swingJava swing
Java swing
Nataraj Dg
 
Applet java
Applet javaApplet java
Applet java
Jorge Luis Tinoco
 
Java Swing
Java SwingJava Swing
Java Swing
Shraddha
 
Java Applet and Graphics
Java Applet and GraphicsJava Applet and Graphics
Java Applet and Graphics
Abdul Rahman Sherzad
 
java swing tutorial for beginners(java programming tutorials)
java swing tutorial for beginners(java programming tutorials)java swing tutorial for beginners(java programming tutorials)
java swing tutorial for beginners(java programming tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
String handling(string class)
String handling(string class)String handling(string class)
String handling(string class)
Ravi Kant Sahu
 
Java: Java Applets
Java: Java AppletsJava: Java Applets
Java: Java Applets
Tareq Hasan
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
mcanotes
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC Structure
Dipika Wadhvani
 
Open and Close Door ppt
 Open and Close Door ppt Open and Close Door ppt
Open and Close Door ppt
Devyani Vaidya
 
L13 string handling(string class)
L13 string handling(string class)L13 string handling(string class)
L13 string handling(string class)
teach4uin
 
Latest seminar topics
Latest seminar topicsLatest seminar topics
Latest seminar topics
Pulla Surya
 
Java Programming- Introduction to Java Applet Programs
Java Programming- Introduction to Java Applet ProgramsJava Programming- Introduction to Java Applet Programs
Java Programming- Introduction to Java Applet Programs
Trinity Dwarka
 
String and string buffer
String and string bufferString and string buffer
String and string buffer
kamal kotecha
 
Java Swing
Java SwingJava Swing
Java Swing
Shraddha
 
String handling(string class)
String handling(string class)String handling(string class)
String handling(string class)
Ravi Kant Sahu
 
Ad

Similar to ITFT- Applet in java (20)

Advanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.pptAdvanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.ppt
miki304759
 
Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01
Abhishek Khune
 
Applet (1)
Applet (1)Applet (1)
Applet (1)
DEEPIKA T
 
Till applet skeleton
Till applet skeletonTill applet skeleton
Till applet skeleton
SouvikKole
 
Oops
OopsOops
Oops
RichaDasila
 
Java applet
Java appletJava applet
Java applet
Elizabeth alexander
 
Applets in Java. Learn java program with applets
Applets in Java. Learn java program with appletsApplets in Java. Learn java program with applets
Applets in Java. Learn java program with applets
halaplay385
 
Applet programming1
Applet programming1Applet programming1
Applet programming1
Shah Ishtiyaq Mehfooze
 
Applet
AppletApplet
Applet
Priyanka Pradhan
 
Appletjava
AppletjavaAppletjava
Appletjava
DEEPIKA T
 
Applet1 (1).pptx
Applet1 (1).pptxApplet1 (1).pptx
Applet1 (1).pptx
FahanaAbdulVahab
 
Applet Life Cycle in Java with brief introduction
Applet Life Cycle in Java with brief introductionApplet Life Cycle in Java with brief introduction
Applet Life Cycle in Java with brief introduction
devicse
 
Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programming
Kuntal Bhowmick
 
Applet in java new
Applet in java newApplet in java new
Applet in java new
Kavitha713564
 
Lecture1 oopj
Lecture1 oopjLecture1 oopj
Lecture1 oopj
Dhairya Joshi
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
Gary Mendonca
 
Applets
AppletsApplets
Applets
poojapainter
 
Java programming Java programming Java programming
Java programming Java programming Java programmingJava programming Java programming Java programming
Java programming Java programming Java programming
Fadlie Ahdon
 
APPLET.pptx
APPLET.pptxAPPLET.pptx
APPLET.pptx
Aishwarya SenthilNathan
 
Applet
 Applet Applet
Applet
swapnac12
 
Advanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.pptAdvanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.ppt
miki304759
 
Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01
Abhishek Khune
 
Till applet skeleton
Till applet skeletonTill applet skeleton
Till applet skeleton
SouvikKole
 
Applets in Java. Learn java program with applets
Applets in Java. Learn java program with appletsApplets in Java. Learn java program with applets
Applets in Java. Learn java program with applets
halaplay385
 
Applet Life Cycle in Java with brief introduction
Applet Life Cycle in Java with brief introductionApplet Life Cycle in Java with brief introduction
Applet Life Cycle in Java with brief introduction
devicse
 
Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programming
Kuntal Bhowmick
 
Java programming Java programming Java programming
Java programming Java programming Java programmingJava programming Java programming Java programming
Java programming Java programming Java programming
Fadlie Ahdon
 
Ad

More from Atul Sehdev (9)

itft-Overview of java language
itft-Overview of java languageitft-Overview of java language
itft-Overview of java language
Atul Sehdev
 
itft-Operators in java
itft-Operators in javaitft-Operators in java
itft-Operators in java
Atul Sehdev
 
itft-Java evolution
itft-Java evolutionitft-Java evolution
itft-Java evolution
Atul Sehdev
 
itft-Inheritance in java
itft-Inheritance in javaitft-Inheritance in java
itft-Inheritance in java
Atul Sehdev
 
itft-Fundamentals of object–oriented programming in java
itft-Fundamentals of object–oriented programming in javaitft-Fundamentals of object–oriented programming in java
itft-Fundamentals of object–oriented programming in java
Atul Sehdev
 
itft-Decision making and branching in java
itft-Decision making and branching in javaitft-Decision making and branching in java
itft-Decision making and branching in java
Atul Sehdev
 
ITFT-Constants, variables and data types in java
ITFT-Constants, variables and data types in javaITFT-Constants, variables and data types in java
ITFT-Constants, variables and data types in java
Atul Sehdev
 
ITFT-Classes and object in java
ITFT-Classes and object in javaITFT-Classes and object in java
ITFT-Classes and object in java
Atul Sehdev
 
ITFT- C,c++,java and world wide web
ITFT- C,c++,java and world wide webITFT- C,c++,java and world wide web
ITFT- C,c++,java and world wide web
Atul Sehdev
 
itft-Overview of java language
itft-Overview of java languageitft-Overview of java language
itft-Overview of java language
Atul Sehdev
 
itft-Operators in java
itft-Operators in javaitft-Operators in java
itft-Operators in java
Atul Sehdev
 
itft-Java evolution
itft-Java evolutionitft-Java evolution
itft-Java evolution
Atul Sehdev
 
itft-Inheritance in java
itft-Inheritance in javaitft-Inheritance in java
itft-Inheritance in java
Atul Sehdev
 
itft-Fundamentals of object–oriented programming in java
itft-Fundamentals of object–oriented programming in javaitft-Fundamentals of object–oriented programming in java
itft-Fundamentals of object–oriented programming in java
Atul Sehdev
 
itft-Decision making and branching in java
itft-Decision making and branching in javaitft-Decision making and branching in java
itft-Decision making and branching in java
Atul Sehdev
 
ITFT-Constants, variables and data types in java
ITFT-Constants, variables and data types in javaITFT-Constants, variables and data types in java
ITFT-Constants, variables and data types in java
Atul Sehdev
 
ITFT-Classes and object in java
ITFT-Classes and object in javaITFT-Classes and object in java
ITFT-Classes and object in java
Atul Sehdev
 
ITFT- C,c++,java and world wide web
ITFT- C,c++,java and world wide webITFT- C,c++,java and world wide web
ITFT- C,c++,java and world wide web
Atul Sehdev
 

Recently uploaded (20)

Overview Well-Being and Creative Careers
Overview Well-Being and Creative CareersOverview Well-Being and Creative Careers
Overview Well-Being and Creative Careers
University of Amsterdam
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
Arshad Shaikh
 
UPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guideUPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guide
abmerca
 
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE  BY sweety Tamanna Mahapatra MSc PediatricAPGAR SCORE  BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
SweetytamannaMohapat
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
Ancient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian HistoryAncient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian History
Virag Sontakke
 
Cultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptxCultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptx
UmeshTimilsina1
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
Ajanta Paintings: Study as a Source of History
Ajanta Paintings: Study as a Source of HistoryAjanta Paintings: Study as a Source of History
Ajanta Paintings: Study as a Source of History
Virag Sontakke
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
Overview Well-Being and Creative Careers
Overview Well-Being and Creative CareersOverview Well-Being and Creative Careers
Overview Well-Being and Creative Careers
University of Amsterdam
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
*"The Segmented Blueprint: Unlocking Insect Body Architecture"*.pptx
Arshad Shaikh
 
UPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guideUPMVLE migration to ARAL. A step- by- step guide
UPMVLE migration to ARAL. A step- by- step guide
abmerca
 
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE  BY sweety Tamanna Mahapatra MSc PediatricAPGAR SCORE  BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
SweetytamannaMohapat
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
Ancient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian HistoryAncient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian History
Virag Sontakke
 
Cultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptxCultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptx
UmeshTimilsina1
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
Ajanta Paintings: Study as a Source of History
Ajanta Paintings: Study as a Source of HistoryAjanta Paintings: Study as a Source of History
Ajanta Paintings: Study as a Source of History
Virag Sontakke
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 

ITFT- Applet in java

  • 2. 2 Introduction We can write two kinds of program in JAVA they are APPLICATION BASED APPLET BASED The application based programs are the programs which are used in the places such as super markets, hospitals etc. The applet based program is used for the development of Graphics .
  • 3. APPLETS APPLET is a small application embedded in HTML page, which is accessed & transported over the Internet , automatically installed into client machines and run as part of web page. Applet are great for creating dynamic & interactive web applications . Applet is a self executing program .
  • 4. Init() : initializes applet before loading. Start(): starts execution of applet Paint(): graphics created Stop(): stops any operation Destroy(): applet completes execution To create applet , Applet class from java. applet package should be imported so tht they are automatically run by any applet program Applet Life Cycle
  • 6. The init() method  The init method is invoked after the applet is created or recreated.  A subclass of Applet should overrides this method if the subclass has an initialization to perform.  Usually includes creating new thread, loading images, setting up GUI components
  • 7. Start() method  The start method is invoked after the init method.  Called whenever the applet become active  A subclass of Applet overrides this method if it has any operation that needs to be performed whenever the webpage is visited.  An applet with animation might use the start method to resume animation
  • 8. Stop() method  The stop method is the opposite of the start method.  Is invoked when the user leave the page.  A subclass of Applet overrides this method if it has any operation that needs to be performed  When the user leaves the page, any threads that applet has started but not completed will continue to run. You should override the stop method to suspend the running threads so that the applet does not take up system resources when it is inactive
  • 9. Destroy() method  The destroy() method is invoked when the browser exits normally to inform the applet that is no longer needed and should release any resources it has allocated.  The stop method is always called before the destroy method  A subclass of Applet overrides this method if it has any operation that needs to be performed before it is destroyed  Usually you won’t need to override this method unless you wish to release specific resources, such as threads that the applet created
  • 10. A SIMPLE APPLET import java.applet.*; import java.awt.*; public class MyApplet extends Applet { public void paint (Graphics g) { g.drawString ("Hi this is my first Applet program", 25, 50); } }
  • 11. 11 Adding applet to Html File • You can only run an applet in an HTML page • The HTML looks something like this: • <html> <body> <h1>Myapplet Applet</h1> <applet code=“Myapplet.class" width="250" height="200"> </applet> </body> </html>
  • 12. Running Applet in AppletViewer • Compiling javac Myapplet.java • Running appletviewer Myapplet.java Applet viewer is a command line program to run Java applets.
  翻译: