SlideShare a Scribd company logo
Applet and Graphics
Programming
Applet Programming
• Applets are small Java programs that are primarily used
in Internet computing.
• They can be transported over the Internet from one
computer to another and run using the Applet Viewer or
any Web browser that supports Java.
• An applet, like any application program, can do many
things for us. It can perform arithmetic operations,
display graphics, play sounds, accept user input, create
animation, and play interactive games.
Local and Remote Applets
• An applet developed locally and stored in a local system
is known as a local applet.
• A remote applet is that which is developed by someone
else and stored on a remote computer connected to the
Internet.
• In order to locate and load a remote applet, we must
know the applet’s address on the Web. This address is
known as Uniform Resource Locator(URL).
How Applets differ from
Applications
• Applets do not use the main() methods for initiating the
execution of the code.
• Unlike stand-alone applications, applets cannot be run
independently. They are run from inside a Web page
using a special feature known as HTML tag.
• Applets cannot read from or write to the files in the local
computer.
• Applets cannot communicate with other servers on the
network.
• Applets cannot run any program the local computer.
• Applets are restricted form using libraries form other
languages such as C or C++.
To Write Applets
• Building an applet code (.java file)
• Creating an executable applet (*.class file)
• Designing a Web page using HTML tags
• Preparing <APPLET> tag
• Incorporating <APPLET> tag into the Web page
• Creating HTML file
• Testing the applet code
Chain of classes inherited by Applet
Class
java..lang.Object
java.applet.Applet
java.awt.Panel
java.awt.Container
java.awt.Component
Applet Life Cycle
• The applet states include:
– Born or initialization state
– Running state
– Idle state
– Dead or destroyed state
Born
Running Idle
Dead
Begin
(Load Applet)
Initalization
Start( )
stop( )
start( )
Stopped
destroy ( )
EndDestroyed
Exit of Broswer
paint ( )
Display
An applet’s state transition diagram
Applet Life Cycle
• Initialization State
– Applet enters the initialization state when it is first loaded. This
is achieved by calling the init( ) method of Applet Class.
– The applet is born.
– The initialization occurs only once in the applets’life cycle.
– To provide any of the behaviours mentioned above, we must
override the init ( ) method:
public void init( )
{
//statements
}
• Running State
– Applet enters the running state when the system calls the start
( ) method of Applet Class.
– The occurs automatically after the applet is initialized.
– Starting can also occur if the applet is already in “stopped”
(Idle ) state.
– Unlike init( ) method, the start ( ) method may be called more
than once.
public void start()
{
// statements
}
Applet Life Cycle
• Idle or Stopped State
– An applet becomes idle when it is stopped from running.
Stopping occurs automatically when we leave the page
containing the currently running applet.
public void stop( )
{
//statements
}
Applet Life Cycle
• Dead State
– An applet is said to be dead when it is removed from memory.
This occurs automatically by invoking the destroy ( ) method
when we quit the browser.
– Like initialization, destroying stage occurs only once in the
applet’s life cycle.
public void destroy( )
{
//statements
}
Applet Life Cycle
• Display state
– Applet moves to the display state whenever it has to perform some
output operations on the screen.
– This happens immediately after the applet enters into the running
state.
– The paint( ) method is called to accomplish this task.
– Almost every applet will have a paint( ) method.
– Paint( ) method is inherited form the Component class , a super class
of Applet.
public void paint (Graphics g)
{
//statements
}
Applet Life Cycle
import java.awt.*;
import java.applet.*;
public class HelloJava extends Applet
{
public void paint(Graphics g)
{
g.drawString("Hello Java",10,100);
}
}
<html>
<body>
<applet code = "HelloJava.class"
height=“100” width =“200”>
</applet>
</body></html>
Applet Tag
• The <Applet. .>tag supplies the name of the applet to be
loaded and tells the browser how much space the applet
requires.
• <APPLET> tag specifies three things:
– Same of the applet
– Width of the applet (in pixels)
– Height of the applet (in pixels)
Passing Parameters to Applets
• We can supply user-defined parameters to an applet using
<PARAM…> tags.
• Each <PARAM…>tag has a name attribute such as color and a value
attribute such as red.
• Inside the applet code, the applet can refer to that parameter by name
to find its value.
• To set up and handle parameters, we need to do two things:
– Include appropriate <PARAM…> tags in the HTML document
– Provide Code in the applet to parse these parameters.
• Parameters are passed to an applet when it is loaded. We can define
the init() method in the applet to get hold of the parameters defined in
the <PARAM> tags.
• This is done using the getParameter( ) method, which takes one string
argument representing the name of the parameter and returns a string
containing the value of the parameter.
import java.awt.*;
import java.applet.*;
public class JavaParam extends Applet
{
String s;
public void init()
{
s =
getParameter("uname");
if(s==null)
s = “ABC”;
s = "Hello" + s;
}
public void paint(Graphics g)
{
g.drawString(s,10,100);
}
}
<html>
<body>
<APPLE CODE =
JavaParam.class
width=400 height = 200>
<PARAM NAME = "uname"
VALUE="ruchita">
</APPLE>
</body>
</html>

More Related Content

What's hot

java interface and packages
java interface and packagesjava interface and packages
java interface and packages
VINOTH R
 
Java-java virtual machine
Java-java virtual machineJava-java virtual machine
Java-java virtual machine
Surbhi Panhalkar
 
Graphics programming in Java
Graphics programming in JavaGraphics programming in Java
Graphics programming in Java
Tushar B Kute
 
Applet programming
Applet programming Applet programming
Applet programming
Devyani Vaidya
 
Java applets
Java appletsJava applets
Java Applet
Java AppletJava Applet
Java layoutmanager
Java layoutmanagerJava layoutmanager
Java layoutmanager
Arati Gadgil
 
Applet life cycle
Applet life cycleApplet life cycle
Applet life cycle
myrajendra
 
Packages in java
Packages in javaPackages in java
Packages in java
Elizabeth alexander
 
Applets in java
Applets in javaApplets in java
Applets in java
Wani Zahoor
 
Java interface
Java interface Java interface
Java interface
HoneyChintal
 
File handling
File handlingFile handling
File handling
priya_trehan
 
Applet in java
Applet in javaApplet in java
Applet in java
Jancypriya M
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
Spotle.ai
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
Hitesh Kumar
 
JRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVAJRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVA
Mehak Tawakley
 
Java applet
Java appletJava applet
Java applet
Elizabeth alexander
 
Java applet - java
Java applet - javaJava applet - java
Java applet - java
Rubaya Mim
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
Shubham Dwivedi
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
Pooja Jaiswal
 

What's hot (20)

java interface and packages
java interface and packagesjava interface and packages
java interface and packages
 
Java-java virtual machine
Java-java virtual machineJava-java virtual machine
Java-java virtual machine
 
Graphics programming in Java
Graphics programming in JavaGraphics programming in Java
Graphics programming in Java
 
Applet programming
Applet programming Applet programming
Applet programming
 
Java applets
Java appletsJava applets
Java applets
 
Java Applet
Java AppletJava Applet
Java Applet
 
Java layoutmanager
Java layoutmanagerJava layoutmanager
Java layoutmanager
 
Applet life cycle
Applet life cycleApplet life cycle
Applet life cycle
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Applets in java
Applets in javaApplets in java
Applets in java
 
Java interface
Java interface Java interface
Java interface
 
File handling
File handlingFile handling
File handling
 
Applet in java
Applet in javaApplet in java
Applet in java
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
JRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVAJRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVA
 
Java applet
Java appletJava applet
Java applet
 
Java applet - java
Java applet - javaJava applet - java
Java applet - java
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 

Viewers also liked

Java Applet and Graphics
Java Applet and GraphicsJava Applet and Graphics
Java Applet and Graphics
Abdul Rahman Sherzad
 
ITFT- Applet in java
ITFT- Applet in javaITFT- Applet in java
ITFT- Applet in java
Atul Sehdev
 
Java applet
Java appletJava applet
Java applet
Arati Gadgil
 
Java Graphics Programming
Java Graphics ProgrammingJava Graphics Programming
Java Graphics Programming
Riccardo Cardin
 
Javalecture 1
Javalecture 1Javalecture 1
Javalecture 1
mrinalbhutani
 
Client Side Programming with Applet
Client Side Programming with AppletClient Side Programming with Applet
Client Side Programming with Applet
backdoor
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
Adil Mehmoood
 
Satish training ppt
Satish training pptSatish training ppt
Satish training ppt
satish lariya
 
JavaYDL13
JavaYDL13JavaYDL13
JavaYDL13
Terry Yoast
 
Basics of applets.53
Basics of applets.53Basics of applets.53
Basics of applets.53
myrajendra
 
Srgoc java
Srgoc javaSrgoc java
Srgoc java
Gaurav Singh
 
L5 classes, objects, nested and inner class
L5 classes, objects, nested and inner classL5 classes, objects, nested and inner class
L5 classes, objects, nested and inner class
teach4uin
 
exception handling
exception handlingexception handling
exception handling
Manav Dharman
 
Java Applet
Java AppletJava Applet
Java Applet
Athharul Haq
 
L18 applets
L18 appletsL18 applets
L18 applets
teach4uin
 
Static keyword ppt
Static keyword pptStatic keyword ppt
Static keyword ppt
Vinod Kumar
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
Ankit Kumar
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
BHUVIJAYAVELU
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
Shraddha
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
Pratik Soares
 

Viewers also liked (20)

Java Applet and Graphics
Java Applet and GraphicsJava Applet and Graphics
Java Applet and Graphics
 
ITFT- Applet in java
ITFT- Applet in javaITFT- Applet in java
ITFT- Applet in java
 
Java applet
Java appletJava applet
Java applet
 
Java Graphics Programming
Java Graphics ProgrammingJava Graphics Programming
Java Graphics Programming
 
Javalecture 1
Javalecture 1Javalecture 1
Javalecture 1
 
Client Side Programming with Applet
Client Side Programming with AppletClient Side Programming with Applet
Client Side Programming with Applet
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
Satish training ppt
Satish training pptSatish training ppt
Satish training ppt
 
JavaYDL13
JavaYDL13JavaYDL13
JavaYDL13
 
Basics of applets.53
Basics of applets.53Basics of applets.53
Basics of applets.53
 
Srgoc java
Srgoc javaSrgoc java
Srgoc java
 
L5 classes, objects, nested and inner class
L5 classes, objects, nested and inner classL5 classes, objects, nested and inner class
L5 classes, objects, nested and inner class
 
exception handling
exception handlingexception handling
exception handling
 
Java Applet
Java AppletJava Applet
Java Applet
 
L18 applets
L18 appletsL18 applets
L18 applets
 
Static keyword ppt
Static keyword pptStatic keyword ppt
Static keyword ppt
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 

Similar to Applet and graphics programming

applet.pptx
applet.pptxapplet.pptx
applet.pptx
SachinBhosale73
 
Applet
AppletApplet
Applet
Amir Shokri
 
Applet intro
Applet introApplet intro
Applet intro
Nitin Birari
 
Java applet
Java appletJava applet
Java applet
GaneshKumarKanthiah
 
Applets
AppletsApplets
Applets
Nuha Noor
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
RamaPrabha24
 
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: Java Applets
Java: Java AppletsJava: Java Applets
Java: Java Applets
Tareq Hasan
 
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
 
Unit 7 Java
Unit 7 JavaUnit 7 Java
Unit 7 Java
arnold 7490
 
Java files and io streams
Java files and io streamsJava files and io streams
Java files and io streams
RubaNagarajan
 
Oops
OopsOops
Java applet basics
Java applet basicsJava applet basics
Java applet basics
Sunil Pandey
 
java programming - applets
java programming - appletsjava programming - applets
java programming - applets
HarshithaAllu
 
Applet.pptx
Applet.pptxApplet.pptx
Applet.pptx
LakachewYezihalem
 
Till applet skeleton
Till applet skeletonTill applet skeleton
Till applet skeleton
SouvikKole
 
Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01
Abhishek Khune
 
Applet in java new
Applet in java newApplet in java new
Applet in java new
Kavitha713564
 
Jsp applet
Jsp appletJsp applet
Jsp applet
Sanoj Kumar
 
oops with java modules iii & iv.pptx
oops with java modules iii & iv.pptxoops with java modules iii & iv.pptx
oops with java modules iii & iv.pptx
rani marri
 

Similar to Applet and graphics programming (20)

applet.pptx
applet.pptxapplet.pptx
applet.pptx
 
Applet
AppletApplet
Applet
 
Applet intro
Applet introApplet intro
Applet intro
 
Java applet
Java appletJava applet
Java applet
 
Applets
AppletsApplets
Applets
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
 
Advanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.pptAdvanced Programming, Java Programming, Applets.ppt
Advanced Programming, Java Programming, Applets.ppt
 
Java: Java Applets
Java: Java AppletsJava: Java Applets
Java: Java Applets
 
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
 
Unit 7 Java
Unit 7 JavaUnit 7 Java
Unit 7 Java
 
Java files and io streams
Java files and io streamsJava files and io streams
Java files and io streams
 
Oops
OopsOops
Oops
 
Java applet basics
Java applet basicsJava applet basics
Java applet basics
 
java programming - applets
java programming - appletsjava programming - applets
java programming - applets
 
Applet.pptx
Applet.pptxApplet.pptx
Applet.pptx
 
Till applet skeleton
Till applet skeletonTill applet skeleton
Till applet skeleton
 
Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01
 
Applet in java new
Applet in java newApplet in java new
Applet in java new
 
Jsp applet
Jsp appletJsp applet
Jsp applet
 
oops with java modules iii & iv.pptx
oops with java modules iii & iv.pptxoops with java modules iii & iv.pptx
oops with java modules iii & iv.pptx
 

Recently uploaded

BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
nitinpv4ai
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
National Information Standards Organization (NISO)
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
giancarloi8888
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
melliereed
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
imrankhan141184
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
MysoreMuleSoftMeetup
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
Steve Thomason
 

Recently uploaded (20)

BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
 

Applet and graphics programming

  • 2. Applet Programming • Applets are small Java programs that are primarily used in Internet computing. • They can be transported over the Internet from one computer to another and run using the Applet Viewer or any Web browser that supports Java. • An applet, like any application program, can do many things for us. It can perform arithmetic operations, display graphics, play sounds, accept user input, create animation, and play interactive games.
  • 3. Local and Remote Applets • An applet developed locally and stored in a local system is known as a local applet. • A remote applet is that which is developed by someone else and stored on a remote computer connected to the Internet. • In order to locate and load a remote applet, we must know the applet’s address on the Web. This address is known as Uniform Resource Locator(URL).
  • 4. How Applets differ from Applications • Applets do not use the main() methods for initiating the execution of the code. • Unlike stand-alone applications, applets cannot be run independently. They are run from inside a Web page using a special feature known as HTML tag. • Applets cannot read from or write to the files in the local computer. • Applets cannot communicate with other servers on the network. • Applets cannot run any program the local computer. • Applets are restricted form using libraries form other languages such as C or C++.
  • 5. To Write Applets • Building an applet code (.java file) • Creating an executable applet (*.class file) • Designing a Web page using HTML tags • Preparing <APPLET> tag • Incorporating <APPLET> tag into the Web page • Creating HTML file • Testing the applet code
  • 6. Chain of classes inherited by Applet Class java..lang.Object java.applet.Applet java.awt.Panel java.awt.Container java.awt.Component
  • 7. Applet Life Cycle • The applet states include: – Born or initialization state – Running state – Idle state – Dead or destroyed state
  • 8. Born Running Idle Dead Begin (Load Applet) Initalization Start( ) stop( ) start( ) Stopped destroy ( ) EndDestroyed Exit of Broswer paint ( ) Display An applet’s state transition diagram
  • 9. Applet Life Cycle • Initialization State – Applet enters the initialization state when it is first loaded. This is achieved by calling the init( ) method of Applet Class. – The applet is born. – The initialization occurs only once in the applets’life cycle. – To provide any of the behaviours mentioned above, we must override the init ( ) method: public void init( ) { //statements }
  • 10. • Running State – Applet enters the running state when the system calls the start ( ) method of Applet Class. – The occurs automatically after the applet is initialized. – Starting can also occur if the applet is already in “stopped” (Idle ) state. – Unlike init( ) method, the start ( ) method may be called more than once. public void start() { // statements } Applet Life Cycle
  • 11. • Idle or Stopped State – An applet becomes idle when it is stopped from running. Stopping occurs automatically when we leave the page containing the currently running applet. public void stop( ) { //statements } Applet Life Cycle
  • 12. • Dead State – An applet is said to be dead when it is removed from memory. This occurs automatically by invoking the destroy ( ) method when we quit the browser. – Like initialization, destroying stage occurs only once in the applet’s life cycle. public void destroy( ) { //statements } Applet Life Cycle
  • 13. • Display state – Applet moves to the display state whenever it has to perform some output operations on the screen. – This happens immediately after the applet enters into the running state. – The paint( ) method is called to accomplish this task. – Almost every applet will have a paint( ) method. – Paint( ) method is inherited form the Component class , a super class of Applet. public void paint (Graphics g) { //statements } Applet Life Cycle
  • 14. import java.awt.*; import java.applet.*; public class HelloJava extends Applet { public void paint(Graphics g) { g.drawString("Hello Java",10,100); } } <html> <body> <applet code = "HelloJava.class" height=“100” width =“200”> </applet> </body></html>
  • 15. Applet Tag • The <Applet. .>tag supplies the name of the applet to be loaded and tells the browser how much space the applet requires. • <APPLET> tag specifies three things: – Same of the applet – Width of the applet (in pixels) – Height of the applet (in pixels)
  • 16. Passing Parameters to Applets • We can supply user-defined parameters to an applet using <PARAM…> tags. • Each <PARAM…>tag has a name attribute such as color and a value attribute such as red. • Inside the applet code, the applet can refer to that parameter by name to find its value. • To set up and handle parameters, we need to do two things: – Include appropriate <PARAM…> tags in the HTML document – Provide Code in the applet to parse these parameters. • Parameters are passed to an applet when it is loaded. We can define the init() method in the applet to get hold of the parameters defined in the <PARAM> tags. • This is done using the getParameter( ) method, which takes one string argument representing the name of the parameter and returns a string containing the value of the parameter.
  • 17. import java.awt.*; import java.applet.*; public class JavaParam extends Applet { String s; public void init() { s = getParameter("uname"); if(s==null) s = “ABC”; s = "Hello" + s; } public void paint(Graphics g) { g.drawString(s,10,100); } } <html> <body> <APPLE CODE = JavaParam.class width=400 height = 200> <PARAM NAME = "uname" VALUE="ruchita"> </APPLE> </body> </html>