SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
Applet Life Cycle in Java
In Java, an applet is a special type of program embedded in the web
page to generate dynamic content. Applet is a class in Java.
The applet life cycle can be defined as the process of how the object is
created, started, stopped, and destroyed during the entire execution of
its application. It basically has five core methods namely init(), start(),
stop(), paint() and destroy().These methods are invoked by the browser
to execute.
Along with the browser, the applet also works on the client side, thus
having less processing time.
Methods of Applet Life Cycle
• There are five methods of an applet life cycle, and they are
• init(): The init() method is the first method to run that initializes the
applet. It can be invoked only once at the time of initialization. The
web browser creates the initialized objects, i.e., the web browser
(after checking the security settings) runs the init() method within the
applet.
• start(): The start() method contains the actual code of the applet and
starts the applet. It is invoked immediately after the init() method is
invoked. Every time the browser is loaded or refreshed, the start()
method is invoked. It is also invoked whenever the applet is
maximized, restored, or moving from one tab to another in the
browser. It is in an inactive state until the init() method is invoked.
• stop(): The stop() method stops the execution of the applet. The stop
() method is invoked whenever the applet is stopped, minimized, or
moving from one tab to another in the browser, the stop() method is
invoked. When we go back to that page, the start() method is invoked
again.
• destroy(): The destroy() method destroys the applet after its work is
done. It is invoked when the applet window is closed or when the tab
containing the webpage is closed. It removes the applet object from
memory and is executed only once. We cannot start the applet once
it is destroyed.
• paint(): The paint() method belongs to the Graphics class in Java. It is
used to draw shapes like circle, square, trapezium, etc., in the applet.
It is executed after the start() method and when the browser or
applet windows are resized.
• Sequence of method execution when an applet is executed:
• init()
• start()
• paint()
• Sequence of method execution when an applet is executed:
• stop()
• destroy()
Applet Life Cycle Working
• The Java plug-in software is responsible for managing the life cycle of an
applet.
• An applet is a Java application executed in any web browser and works on
the client-side. It doesn't have the main() method because it runs in the
browser. It is thus created to be placed on an HTML page.
• The init(), start(), stop() and destroy() methods belongs to
the applet.Applet class.
• The paint() method belongs to the awt.Component class.
• In Java, if we want to make a class an Applet class, we need to extend
the Applet
• Whenever we create an applet, we are creating the instance of the existing
Applet class. And thus, we can use all the methods of that class.
Flow of Applet Life Cycle:
class TestAppletLifeCycle extends Applet
{
public void init()
{
// initialized objects
}
public void start()
{
// code to start the applet
}
public void paint(Graphics graphics)
{
// draw the shapes
}
public void stop()
{
// code to stop the applet
}
public void destroy()
{
// code to destroy the applet
}
}
Delegation Event Model in Java
• The Delegation Event model is defined to handle events in
GUI programming languages. The GUI stands for Graphical User
Interface, where a user graphically/visually interacts with the system.
• The Event Delegation Model in java is a mechanism in Java for
handling events. It is based on a hierarchy of containers and
components, with event listeners registered at the top level of the
hierarchy. This allows the container to handle events for all of its
components, improving performance and reducing code duplication.
Event Processing in Java
• The below image demonstrates the event processing.
The modern approach for event processing is based on the Delegation
Model. It defines a standard and compatible mechanism to generate
and process events. In this model, a source generates an event and
forwards it to one or more listeners. The listener waits until it receives
an event. Once it receives the event, it is processed by the listener and
returns it. The UI elements are able to delegate the processing of an
event to a separate function.
Applet Life Cycle in Java with brief introduction
Advantage of the Delegation Event Model
• The advantages of using the Event Delegation Model in Java include
improved performance, reduced code duplication, increased
flexibility, and easier maintenance. The model allows developers to
create applications that are responsive, modular, and easy to
maintain.
• Basically, an Event Model is based on the following three
components:
• Events
• Events Sources
• Events Listeners
How Does the Event Delegation Model Work in
Java?
• The Event Delegation Model is a programming pattern used in Java for
handling events in GUI (Graphical User Interface) applications. It
follows a hierarchical structure, where the events are initially received
by the top-level container and then delegated to the appropriate
component for processing.

More Related Content

PDF
PPTX
Object Oriented Design
PPT
Exception Handling in JAVA
PPTX
Modules and modularization criteria
PPT
Working with color and font
PDF
Java variable types
PPT
Applet life cycle
PPTX
Object Oriented Design
Exception Handling in JAVA
Modules and modularization criteria
Working with color and font
Java variable types
Applet life cycle

What's hot (20)

PPT
Java Streams
PPT
Java static keyword
PPT
Java-java virtual machine
PPT
Interrupt
PDF
Major and Minor Elements of Object Model
PPTX
Object model
PPTX
Array ppt
PPTX
Code generation
PPT
Lecture 1 data structures and algorithms
PPTX
Interrupts and types of interrupts
PPTX
Purpose of DBMS and users of DBMS
PPTX
Critical section problem in operating system.
PPTX
Data Types - Premetive and Non Premetive
PPT
9. Input Output in java
PPTX
Packages in java
PPTX
Inheritance in c++
PPTX
Deadlock Prevention
PPTX
JavaScript Conditional Statements
PPTX
anatomy of a jsp page & jsp syntax.pptx
PPTX
JAVA ENVIRONMENT
Java Streams
Java static keyword
Java-java virtual machine
Interrupt
Major and Minor Elements of Object Model
Object model
Array ppt
Code generation
Lecture 1 data structures and algorithms
Interrupts and types of interrupts
Purpose of DBMS and users of DBMS
Critical section problem in operating system.
Data Types - Premetive and Non Premetive
9. Input Output in java
Packages in java
Inheritance in c++
Deadlock Prevention
JavaScript Conditional Statements
anatomy of a jsp page & jsp syntax.pptx
JAVA ENVIRONMENT
Ad

Similar to Applet Life Cycle in Java with brief introduction (20)

PPTX
21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx
PPT
Advanced Programming, Java Programming, Applets.ppt
PPTX
Java applet
PPT
Java programming Java programming Java programming
PPTX
Java Apple dndkorksnsbsjdkkdjejdjrdndjdj
PPTX
Applet (1)
PPT
Applet Architecture - Introducing Java Applets
PPTX
Applets in Java
PPTX
Applets in Java
PPTX
Applets
PPT
Basic of Applet
PDF
ITFT- Applet in java
PPTX
java.pptx
DOCX
Lecture1 oopj
PPTX
Appletjava
PDF
27 applet programming
PPTX
Applets in Java. Learn java program with applets
PPTX
PPTX
Applet1 (1).pptx
21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx
Advanced Programming, Java Programming, Applets.ppt
Java applet
Java programming Java programming Java programming
Java Apple dndkorksnsbsjdkkdjejdjrdndjdj
Applet (1)
Applet Architecture - Introducing Java Applets
Applets in Java
Applets in Java
Applets
Basic of Applet
ITFT- Applet in java
java.pptx
Lecture1 oopj
Appletjava
27 applet programming
Applets in Java. Learn java program with applets
Applet1 (1).pptx
Ad

Recently uploaded (20)

PDF
Top 10 read articles In Managing Information Technology.pdf
PDF
오픈소스 LLM, vLLM으로 Production까지 (Instruct.KR Summer Meetup, 2025)
PDF
dse_final_merit_2025_26 gtgfffffcjjjuuyy
PDF
July 2025: Top 10 Read Articles Advanced Information Technology
PDF
Monitoring Global Terrestrial Surface Water Height using Remote Sensing - ARS...
PPTX
TE-AI-Unit VI notes using planning model
PDF
B.Tech (Electrical Engineering ) 2024 syllabus.pdf
PDF
Principles of Food Science and Nutritions
PPTX
24AI201_AI_Unit_4 (1).pptx Artificial intelligence
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
Introduction to Data Science: data science process
PPTX
Practice Questions on recent development part 1.pptx
PPTX
meets orient on the new industry intereacting skills .pptx
PPTX
Internship_Presentation_Final engineering.pptx
PDF
International Journal of Information Technology Convergence and Services (IJI...
PPTX
Ship’s Structural Components.pptx 7.7 Mb
PDF
ETO & MEO Certificate of Competency Questions and Answers
PDF
flutter Launcher Icons, Splash Screens & Fonts
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPT
SCOPE_~1- technology of green house and poyhouse
Top 10 read articles In Managing Information Technology.pdf
오픈소스 LLM, vLLM으로 Production까지 (Instruct.KR Summer Meetup, 2025)
dse_final_merit_2025_26 gtgfffffcjjjuuyy
July 2025: Top 10 Read Articles Advanced Information Technology
Monitoring Global Terrestrial Surface Water Height using Remote Sensing - ARS...
TE-AI-Unit VI notes using planning model
B.Tech (Electrical Engineering ) 2024 syllabus.pdf
Principles of Food Science and Nutritions
24AI201_AI_Unit_4 (1).pptx Artificial intelligence
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Introduction to Data Science: data science process
Practice Questions on recent development part 1.pptx
meets orient on the new industry intereacting skills .pptx
Internship_Presentation_Final engineering.pptx
International Journal of Information Technology Convergence and Services (IJI...
Ship’s Structural Components.pptx 7.7 Mb
ETO & MEO Certificate of Competency Questions and Answers
flutter Launcher Icons, Splash Screens & Fonts
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
SCOPE_~1- technology of green house and poyhouse

Applet Life Cycle in Java with brief introduction

  • 1. Applet Life Cycle in Java In Java, an applet is a special type of program embedded in the web page to generate dynamic content. Applet is a class in Java. The applet life cycle can be defined as the process of how the object is created, started, stopped, and destroyed during the entire execution of its application. It basically has five core methods namely init(), start(), stop(), paint() and destroy().These methods are invoked by the browser to execute. Along with the browser, the applet also works on the client side, thus having less processing time.
  • 2. Methods of Applet Life Cycle
  • 3. • There are five methods of an applet life cycle, and they are • init(): The init() method is the first method to run that initializes the applet. It can be invoked only once at the time of initialization. The web browser creates the initialized objects, i.e., the web browser (after checking the security settings) runs the init() method within the applet. • start(): The start() method contains the actual code of the applet and starts the applet. It is invoked immediately after the init() method is invoked. Every time the browser is loaded or refreshed, the start() method is invoked. It is also invoked whenever the applet is maximized, restored, or moving from one tab to another in the browser. It is in an inactive state until the init() method is invoked.
  • 4. • stop(): The stop() method stops the execution of the applet. The stop () method is invoked whenever the applet is stopped, minimized, or moving from one tab to another in the browser, the stop() method is invoked. When we go back to that page, the start() method is invoked again. • destroy(): The destroy() method destroys the applet after its work is done. It is invoked when the applet window is closed or when the tab containing the webpage is closed. It removes the applet object from memory and is executed only once. We cannot start the applet once it is destroyed. • paint(): The paint() method belongs to the Graphics class in Java. It is used to draw shapes like circle, square, trapezium, etc., in the applet. It is executed after the start() method and when the browser or applet windows are resized.
  • 5. • Sequence of method execution when an applet is executed: • init() • start() • paint() • Sequence of method execution when an applet is executed: • stop() • destroy()
  • 6. Applet Life Cycle Working • The Java plug-in software is responsible for managing the life cycle of an applet. • An applet is a Java application executed in any web browser and works on the client-side. It doesn't have the main() method because it runs in the browser. It is thus created to be placed on an HTML page. • The init(), start(), stop() and destroy() methods belongs to the applet.Applet class. • The paint() method belongs to the awt.Component class. • In Java, if we want to make a class an Applet class, we need to extend the Applet • Whenever we create an applet, we are creating the instance of the existing Applet class. And thus, we can use all the methods of that class.
  • 7. Flow of Applet Life Cycle:
  • 8. class TestAppletLifeCycle extends Applet { public void init() { // initialized objects } public void start() { // code to start the applet } public void paint(Graphics graphics) { // draw the shapes } public void stop() { // code to stop the applet } public void destroy() { // code to destroy the applet } }
  • 9. Delegation Event Model in Java • The Delegation Event model is defined to handle events in GUI programming languages. The GUI stands for Graphical User Interface, where a user graphically/visually interacts with the system. • The Event Delegation Model in java is a mechanism in Java for handling events. It is based on a hierarchy of containers and components, with event listeners registered at the top level of the hierarchy. This allows the container to handle events for all of its components, improving performance and reducing code duplication.
  • 10. Event Processing in Java • The below image demonstrates the event processing. The modern approach for event processing is based on the Delegation Model. It defines a standard and compatible mechanism to generate and process events. In this model, a source generates an event and forwards it to one or more listeners. The listener waits until it receives an event. Once it receives the event, it is processed by the listener and returns it. The UI elements are able to delegate the processing of an event to a separate function.
  • 12. Advantage of the Delegation Event Model • The advantages of using the Event Delegation Model in Java include improved performance, reduced code duplication, increased flexibility, and easier maintenance. The model allows developers to create applications that are responsive, modular, and easy to maintain. • Basically, an Event Model is based on the following three components: • Events • Events Sources • Events Listeners
  • 13. How Does the Event Delegation Model Work in Java? • The Event Delegation Model is a programming pattern used in Java for handling events in GUI (Graphical User Interface) applications. It follows a hierarchical structure, where the events are initially received by the top-level container and then delegated to the appropriate component for processing.