SlideShare a Scribd company logo
1 of 17
APPLETS
Prof. Yashoda M B
Assistant Professor in Computer Science (UG)
Kristu Jayanti College, Autonomous
(Reaccredited A++ Grade by NAAC with CGPA 3.78/4)
Bengaluru – 560077, India
INTRODUCTION
• Applet is a small program
• Can be placed on web page
• Will be executed by the web browser
• Give web page “dynamic content”
• Applet class is one of the AWT component
• Java applets are usually graphical
• Draw graphics in a defined screen area
Important points :
• All applets are sub-classes (either directly or indirectly) of java.applet.Applet class.
• Applets are not stand-alone programs. Instead, they run within either a web browser or an applet viewer. JDK provides a standard applet viewer
tool called applet viewer.
• In general, the execution of an applet does not begin at the main() method.
• Output of an applet window is not performed by System.out.println(). Rather it is handled with various AWT methods, such as drawString().
11/19/2023
Prof. Yashoda M B, Kristu Jayanti College, Bengaluru
2
TYPES OF APPLETS
• Local Applet
• Remote Applet
11/19/2023
Prof. Yashoda M B, Kristu Jayanti College, Bengaluru
3
11/19/2023
Prof. Yashoda M B, Kristu Jayanti College, Bengaluru
4
11/19/2023
Prof. Yashoda M B, Kristu Jayanti College, Bengaluru
5
HOW APPLETS DIFFER FROM APPLICATION
11/19/2023
Prof. Yashoda M B, Kristu Jayanti College, Bengaluru
6
BUILDING APPLET CODE
• Uses the services of two classes, namely Applet and Graphics.
• Applet class in java.applet package
• Graphics class in java.awt package
• Java automatically calls a series of Applet class methods for starting, running,
and stopping the applet code.
• The Applet class therefore maintains the lifecycle of an applet.
11/19/2023
Prof. Yashoda M B, Kristu Jayanti College, Bengaluru
7
CONTD…
• paint() method of the Applet class, when it is called actually displays the result
of the applet code on the screen.
• The output may be text, graphics, or sound.
• The paint() method requires a Graphics object as an argument, as follows:
public void paint(Graphics g)
• All output operations of an applet are performed using the methods defined in
the Graphics class.
11/19/2023
Prof. Yashoda M B, Kristu Jayanti College, Bengaluru
8
GENERAL FORMAT OF APPLET CODE
import java.awt.*;
import java.applet.*;
public class AppletEx extends Applet
{
…………
………….
public void paint(Graphics g)
{
…………….. //applet operation code
…………………
}
…………………
………………....
}
11/19/2023
Prof. Yashoda M B, Kristu Jayanti College, Bengaluru
9
EXAMPLE
java HelloWorld!
Error: Main method not found in class HelloWorld,
please define the main method as:
public static void main(String[] args)
11/19/2023
Prof. Yashoda M B, Kristu Jayanti College, Bengaluru
10
APPLET LIFE CYCLE
11/19/2023
Prof. Yashoda M B, Kristu Jayanti College, Bengaluru
11
CONTD…
• Born or initialization state
• Running state
• Idle state
• Dead or destroyed state
11/19/2023
Prof. Yashoda M B, Kristu Jayanti College, Bengaluru
12
INITIALIZATION STATE
• Applet enters the initialization state when it is first loaded.
• Achieved using init() method
• User can perform the following
• Create objects needed by the applet
• Set up initial values
• Load images
• Setup colors
• Initialization occurs only once in the applet’s life cycle.
• To provide any behaviours mentioned above, we must override the init() method:
public void init()
{
…………
…………
}
11/19/2023
Prof. Yashoda M B, Kristu Jayanti College, Bengaluru
13
RUNNING STATE
• Applet enters the running state when system calls start() method.
• This occurs automatically after the init() method
• Starting can also occur if the applet is there in the stopped state.
• start() method can be called more than once
• we may override the start() method:
public void start()
{
…………
…………
}
11/19/2023
Prof. Yashoda M B, Kristu Jayanti College, Bengaluru
14
IDLE OR STOPPED STATE
• Applet enters the idle state when it stops running.
• When stop() method is called explicitly
• When we leave the page containing currently running
applet
• we may override the stop() method:
public void stop()
{
…………
…………
}
11/19/2023
Prof. Yashoda M B, Kristu Jayanti College, Bengaluru
15
DEAD STATE
• Applet is said to be dead when it is removed from the 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.
• we may override the destroy() method:
public void destroy()
{
…………
…………
}
11/19/2023
Prof. Yashoda M B, Kristu Jayanti College, Bengaluru
16
DISPLAY STATE
• Applet enters the display state whenever it has to perform
some output operation on the screen.
• Achieved using paint() method
• we must override the paint() method:
public void paint(Graphics g)
{
…………
…………
}
11/19/2023
Prof. Yashoda M B, Kristu Jayanti College, Bengaluru
17

More Related Content

Similar to applets.pptx

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
 
Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01
Abhishek Khune
 

Similar to applets.pptx (20)

Java applet programming concepts
Java  applet programming conceptsJava  applet programming concepts
Java applet programming concepts
 
Applet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java AppletsApplet Architecture - Introducing Java Applets
Applet Architecture - Introducing Java Applets
 
Applet
AppletApplet
Applet
 
171-33B - Java Programming-Building Applets.ppt
171-33B - Java Programming-Building Applets.ppt171-33B - Java Programming-Building Applets.ppt
171-33B - Java Programming-Building Applets.ppt
 
Applet
AppletApplet
Applet
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
 
27 applet programming
27  applet programming27  applet programming
27 applet programming
 
Applets
AppletsApplets
Applets
 
APPLET.pptx
APPLET.pptxAPPLET.pptx
APPLET.pptx
 
Applet progming
Applet progmingApplet progming
Applet progming
 
Graphical interpreter report
Graphical interpreter   reportGraphical interpreter   report
Graphical interpreter report
 
Smart material - Unit 3 (2).pdf
Smart material - Unit 3 (2).pdfSmart material - Unit 3 (2).pdf
Smart material - Unit 3 (2).pdf
 
Smart material - Unit 3 (1).pdf
Smart material - Unit 3 (1).pdfSmart material - Unit 3 (1).pdf
Smart material - Unit 3 (1).pdf
 
java Applet Introduction
java Applet Introductionjava Applet Introduction
java Applet Introduction
 
Java: Java Applets
Java: Java AppletsJava: Java Applets
Java: Java Applets
 
Applets in java
Applets in javaApplets in java
Applets in java
 
Unit 7 Java
Unit 7 JavaUnit 7 Java
Unit 7 Java
 
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
 
Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01Slide8appletv2 091028110313-phpapp01
Slide8appletv2 091028110313-phpapp01
 
OpenGL
OpenGLOpenGL
OpenGL
 

More from yashodamb (7)

Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdfUnit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
 
Cascading style sheet: complete explanation with some examples
Cascading style sheet: complete explanation with some examplesCascading style sheet: complete explanation with some examples
Cascading style sheet: complete explanation with some examples
 
Navigation between the worksheets.pptx
Navigation between the worksheets.pptxNavigation between the worksheets.pptx
Navigation between the worksheets.pptx
 
Implementing a Java Program.pptx
Implementing a Java Program.pptxImplementing a Java Program.pptx
Implementing a Java Program.pptx
 
Thread life cycle.pptx
Thread life cycle.pptxThread life cycle.pptx
Thread life cycle.pptx
 
DECISION MAKING STATEMENTS.pptx
DECISION MAKING STATEMENTS.pptxDECISION MAKING STATEMENTS.pptx
DECISION MAKING STATEMENTS.pptx
 
History of C programming.pptx
History of C programming.pptxHistory of C programming.pptx
History of C programming.pptx
 

Recently uploaded

Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 

Recently uploaded (20)

Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 

applets.pptx

  • 1. APPLETS Prof. Yashoda M B Assistant Professor in Computer Science (UG) Kristu Jayanti College, Autonomous (Reaccredited A++ Grade by NAAC with CGPA 3.78/4) Bengaluru – 560077, India
  • 2. INTRODUCTION • Applet is a small program • Can be placed on web page • Will be executed by the web browser • Give web page “dynamic content” • Applet class is one of the AWT component • Java applets are usually graphical • Draw graphics in a defined screen area Important points : • All applets are sub-classes (either directly or indirectly) of java.applet.Applet class. • Applets are not stand-alone programs. Instead, they run within either a web browser or an applet viewer. JDK provides a standard applet viewer tool called applet viewer. • In general, the execution of an applet does not begin at the main() method. • Output of an applet window is not performed by System.out.println(). Rather it is handled with various AWT methods, such as drawString(). 11/19/2023 Prof. Yashoda M B, Kristu Jayanti College, Bengaluru 2
  • 3. TYPES OF APPLETS • Local Applet • Remote Applet 11/19/2023 Prof. Yashoda M B, Kristu Jayanti College, Bengaluru 3
  • 4. 11/19/2023 Prof. Yashoda M B, Kristu Jayanti College, Bengaluru 4
  • 5. 11/19/2023 Prof. Yashoda M B, Kristu Jayanti College, Bengaluru 5
  • 6. HOW APPLETS DIFFER FROM APPLICATION 11/19/2023 Prof. Yashoda M B, Kristu Jayanti College, Bengaluru 6
  • 7. BUILDING APPLET CODE • Uses the services of two classes, namely Applet and Graphics. • Applet class in java.applet package • Graphics class in java.awt package • Java automatically calls a series of Applet class methods for starting, running, and stopping the applet code. • The Applet class therefore maintains the lifecycle of an applet. 11/19/2023 Prof. Yashoda M B, Kristu Jayanti College, Bengaluru 7
  • 8. CONTD… • paint() method of the Applet class, when it is called actually displays the result of the applet code on the screen. • The output may be text, graphics, or sound. • The paint() method requires a Graphics object as an argument, as follows: public void paint(Graphics g) • All output operations of an applet are performed using the methods defined in the Graphics class. 11/19/2023 Prof. Yashoda M B, Kristu Jayanti College, Bengaluru 8
  • 9. GENERAL FORMAT OF APPLET CODE import java.awt.*; import java.applet.*; public class AppletEx extends Applet { ………… …………. public void paint(Graphics g) { …………….. //applet operation code ………………… } ………………… ……………….... } 11/19/2023 Prof. Yashoda M B, Kristu Jayanti College, Bengaluru 9
  • 10. EXAMPLE java HelloWorld! Error: Main method not found in class HelloWorld, please define the main method as: public static void main(String[] args) 11/19/2023 Prof. Yashoda M B, Kristu Jayanti College, Bengaluru 10
  • 11. APPLET LIFE CYCLE 11/19/2023 Prof. Yashoda M B, Kristu Jayanti College, Bengaluru 11
  • 12. CONTD… • Born or initialization state • Running state • Idle state • Dead or destroyed state 11/19/2023 Prof. Yashoda M B, Kristu Jayanti College, Bengaluru 12
  • 13. INITIALIZATION STATE • Applet enters the initialization state when it is first loaded. • Achieved using init() method • User can perform the following • Create objects needed by the applet • Set up initial values • Load images • Setup colors • Initialization occurs only once in the applet’s life cycle. • To provide any behaviours mentioned above, we must override the init() method: public void init() { ………… ………… } 11/19/2023 Prof. Yashoda M B, Kristu Jayanti College, Bengaluru 13
  • 14. RUNNING STATE • Applet enters the running state when system calls start() method. • This occurs automatically after the init() method • Starting can also occur if the applet is there in the stopped state. • start() method can be called more than once • we may override the start() method: public void start() { ………… ………… } 11/19/2023 Prof. Yashoda M B, Kristu Jayanti College, Bengaluru 14
  • 15. IDLE OR STOPPED STATE • Applet enters the idle state when it stops running. • When stop() method is called explicitly • When we leave the page containing currently running applet • we may override the stop() method: public void stop() { ………… ………… } 11/19/2023 Prof. Yashoda M B, Kristu Jayanti College, Bengaluru 15
  • 16. DEAD STATE • Applet is said to be dead when it is removed from the 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. • we may override the destroy() method: public void destroy() { ………… ………… } 11/19/2023 Prof. Yashoda M B, Kristu Jayanti College, Bengaluru 16
  • 17. DISPLAY STATE • Applet enters the display state whenever it has to perform some output operation on the screen. • Achieved using paint() method • we must override the paint() method: public void paint(Graphics g) { ………… ………… } 11/19/2023 Prof. Yashoda M B, Kristu Jayanti College, Bengaluru 17