SlideShare a Scribd company logo
Life cycle of on applet




                          1
Objectives

On completion of this period, you would be able
  to learn
• Life cycle of an applet




                                                  2
Recap

In the last class, you have studied about applet
  classes and applet architecture
• Applet class hierarchy
• Applet methods
• Applet architecture




                                                   3
Applet Life Cycle


• When an applet is loaded, it undergoes a series
  of changes in its state
• The applet states include
  •   Born or initialization state
  •   Running state
  •   Idle state
  •   Dead or destroyed state




                                                    4
Applet Life Cycle                                contd..

    • The changes in state of applet life is shown in
      the following state transition diagram

Begin                   Born         Initialization
(Load applet)
                start()          stop()

  Display            Running                          Idle          Stopped

                                  start()                    destroy()

              paint()
                                Destroyed             Dead               End

                                                Exit browser
        Fig. 57.1 Applet state transition diagram
                                                                                     5
Applet Life Cycle                   contd..

• Initialization state
  •   Applet enter this state when it is first loaded
  •   This is achieved by calling init() method
  •   The init( ) method is the first method to be called
  •    Initialize variables in this method
  •   This method is called only once during the life time of
      your applet




                                                                6
Applet Life Cycle                       contd..

• Running state
  • Applet enters into running state when it calls start()
    method
  • The start( ) method is called after init( )
  • It is also called to restart an applet after it has been
    stopped
  • Where as init( ) is called only once, start() method
    may be called any number of times
  • When a user leaves a web page and comes back, the
    applet resumes execution

                                                           7
Applet Life Cycle            contd..

• Idle or stopped state
  • Applet becomes idle when it is stopped
  • Stopping automatically occurs when we leave
    the page containing the current applet
  • We can achieve this by calling stop() method
  • stop() method suspends applet execution until
    the user clicks on it



                                                 8
Applet Life Cycle                contd..

• Dead state
  • Applet is said to be dead when it is removed
    from memory.
  • This occurs by calling destroy() method
  • The destroy() method perform shutdown
    activities
  • It also removes the applet from the memory



                                                   9
Applet Life Cycle                 contd..

• Display state

   • Applet moves to the display state whenever it has to
     perform some output operation on the screen
   • The paint() method is called to accomplish this task
   • Paint() method does absolutely nothing
   • We have to override this method to display the
     required graphics




                                                            10
Summary
  In this class you, have learnt

• Applet life cycle has different state
  – Born
  – Running
  – Idle
  – Dead




                                          11
Summary           contd..


The method useful for these state change

  – init()
  – start()
  – stop()
  – paint()
  – destroy()


                                           12
Quiz

1. Which method in the life cycle of an applet
    called only once
   a) stop()
   b) start()
   c) init()
   d) destroy()




                                                 13
Quiz                contd..

2. Which method in the life cycle of an applet
    removes the applet from the memory
   a) stop()
   b) start()
   c) init()
   d) destroy()




                                                 14
Frequently Asked Questions

1. Write about the life cycle of an applet




                                             15

More Related Content

What's hot

Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVAAbhilash Nair
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
VINOTH R
 
java interface and packages
java interface and packagesjava interface and packages
java interface and packages
VINOTH R
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
Elizabeth alexander
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
shanmuga rajan
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
Hamid Ghorbani
 
Event handling
Event handlingEvent handling
Event handling
swapnac12
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in javaTech_MX
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
Raja Sekhar
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
kamal kotecha
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
Java threads
Java threadsJava threads
Java threads
Prabhakaran V M
 
Java Streams
Java StreamsJava Streams
Java Streams
M Vishnuvardhan Reddy
 
Java Data Types
Java Data TypesJava Data Types
Java Data Types
Spotle.ai
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
Vinod Kumar
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
CPD INDIA
 
Java Thread Synchronization
Java Thread SynchronizationJava Thread Synchronization
Java Thread SynchronizationBenj Del Mundo
 
File in C language
File in C languageFile in C language
File in C language
Manash Kumar Mondal
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
lalithambiga kamaraj
 

What's hot (20)

Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
Features of java
Features of javaFeatures of java
Features of java
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
 
java interface and packages
java interface and packagesjava interface and packages
java interface and packages
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
 
Event handling
Event handlingEvent handling
Event handling
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
Java threads
Java threadsJava threads
Java threads
 
Java Streams
Java StreamsJava Streams
Java Streams
 
Java Data Types
Java Data TypesJava Data Types
Java Data Types
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
 
Java Thread Synchronization
Java Thread SynchronizationJava Thread Synchronization
Java Thread Synchronization
 
File in C language
File in C languageFile in C language
File in C language
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
 

Similar to Applet life cycle

Applet skelton58
Applet skelton58Applet skelton58
Applet skelton58myrajendra
 
Applet init nd termination.59
Applet init nd termination.59Applet init nd termination.59
Applet init nd termination.59myrajendra
 
Till applet skeleton
Till applet skeletonTill applet skeleton
Till applet skeleton
SouvikKole
 
java Applet Introduction
java Applet Introductionjava Applet Introduction
java Applet Introduction
yugandhar vadlamudi
 
Java applets
Java appletsJava applets
Java applets
Khan Mac-arther
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
mcanotes
 
Applets
AppletsApplets
Applets
Nuha Noor
 
Oops
OopsOops
Applets
AppletsApplets
Applets
Inayat Sharma
 
L18 applets
L18 appletsL18 applets
L18 applets
teach4uin
 
21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx
21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx
21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx
SathwikO33
 
Java chapter 7
Java chapter 7Java chapter 7
Java chapter 7
Abdii Rashid
 
Applet.pptx
Applet.pptxApplet.pptx
Applet.pptx
LakachewYezihalem
 
Simple applet progra.54
Simple applet progra.54Simple applet progra.54
Simple applet progra.54myrajendra
 
Threadlifecycle.36
Threadlifecycle.36Threadlifecycle.36
Threadlifecycle.36myrajendra
 
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
 
Basic of Applet
Basic of AppletBasic of Applet
Basic of Applet
suraj pandey
 
Java applet
Java appletJava applet
Java applet
Elizabeth alexander
 

Similar to Applet life cycle (20)

Applet skelton58
Applet skelton58Applet skelton58
Applet skelton58
 
Applet init nd termination.59
Applet init nd termination.59Applet init nd termination.59
Applet init nd termination.59
 
Till applet skeleton
Till applet skeletonTill applet skeleton
Till applet skeleton
 
java Applet Introduction
java Applet Introductionjava Applet Introduction
java Applet Introduction
 
Java applets
Java appletsJava applets
Java applets
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
 
Applets
AppletsApplets
Applets
 
Oops
OopsOops
Oops
 
Applets
AppletsApplets
Applets
 
Applets
AppletsApplets
Applets
 
L18 applets
L18 appletsL18 applets
L18 applets
 
21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx
21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx
21cs-403c-Concepts of Applets, AWT and Event handling- L1.pptx
 
Java chapter 7
Java chapter 7Java chapter 7
Java chapter 7
 
Applet.pptx
Applet.pptxApplet.pptx
Applet.pptx
 
Simple applet progra.54
Simple applet progra.54Simple applet progra.54
Simple applet progra.54
 
Threadlifecycle.36
Threadlifecycle.36Threadlifecycle.36
Threadlifecycle.36
 
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
 
Basic of Applet
Basic of AppletBasic of Applet
Basic of Applet
 
APPLET.pptx
APPLET.pptxAPPLET.pptx
APPLET.pptx
 
Java applet
Java appletJava applet
Java applet
 

More from myrajendra

Fundamentals
FundamentalsFundamentals
Fundamentals
myrajendra
 
Data type
Data typeData type
Data type
myrajendra
 
Hibernate example1
Hibernate example1Hibernate example1
Hibernate example1
myrajendra
 
Jdbc workflow
Jdbc workflowJdbc workflow
Jdbc workflow
myrajendra
 
2 jdbc drivers
2 jdbc drivers2 jdbc drivers
2 jdbc drivers
myrajendra
 
3 jdbc api
3 jdbc api3 jdbc api
3 jdbc api
myrajendra
 
4 jdbc step1
4 jdbc step14 jdbc step1
4 jdbc step1
myrajendra
 
Dao example
Dao exampleDao example
Dao example
myrajendra
 
Sessionex1
Sessionex1Sessionex1
Sessionex1
myrajendra
 
1 introduction to html
1 introduction to html1 introduction to html
1 introduction to htmlmyrajendra
 
Views
ViewsViews
Views
myrajendra
 

More from myrajendra (20)

Fundamentals
FundamentalsFundamentals
Fundamentals
 
Data type
Data typeData type
Data type
 
Hibernate example1
Hibernate example1Hibernate example1
Hibernate example1
 
Jdbc workflow
Jdbc workflowJdbc workflow
Jdbc workflow
 
2 jdbc drivers
2 jdbc drivers2 jdbc drivers
2 jdbc drivers
 
3 jdbc api
3 jdbc api3 jdbc api
3 jdbc api
 
4 jdbc step1
4 jdbc step14 jdbc step1
4 jdbc step1
 
Dao example
Dao exampleDao example
Dao example
 
Sessionex1
Sessionex1Sessionex1
Sessionex1
 
Internal
InternalInternal
Internal
 
3. elements
3. elements3. elements
3. elements
 
2. attributes
2. attributes2. attributes
2. attributes
 
1 introduction to html
1 introduction to html1 introduction to html
1 introduction to html
 
Headings
HeadingsHeadings
Headings
 
Forms
FormsForms
Forms
 
Css
CssCss
Css
 
Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
Starting jdbc
Starting jdbcStarting jdbc
Starting jdbc
 

Applet life cycle

  • 1. Life cycle of on applet 1
  • 2. Objectives On completion of this period, you would be able to learn • Life cycle of an applet 2
  • 3. Recap In the last class, you have studied about applet classes and applet architecture • Applet class hierarchy • Applet methods • Applet architecture 3
  • 4. Applet Life Cycle • When an applet is loaded, it undergoes a series of changes in its state • The applet states include • Born or initialization state • Running state • Idle state • Dead or destroyed state 4
  • 5. Applet Life Cycle contd.. • The changes in state of applet life is shown in the following state transition diagram Begin Born Initialization (Load applet) start() stop() Display Running Idle Stopped start() destroy() paint() Destroyed Dead End Exit browser Fig. 57.1 Applet state transition diagram 5
  • 6. Applet Life Cycle contd.. • Initialization state • Applet enter this state when it is first loaded • This is achieved by calling init() method • The init( ) method is the first method to be called • Initialize variables in this method • This method is called only once during the life time of your applet 6
  • 7. Applet Life Cycle contd.. • Running state • Applet enters into running state when it calls start() method • The start( ) method is called after init( ) • It is also called to restart an applet after it has been stopped • Where as init( ) is called only once, start() method may be called any number of times • When a user leaves a web page and comes back, the applet resumes execution 7
  • 8. Applet Life Cycle contd.. • Idle or stopped state • Applet becomes idle when it is stopped • Stopping automatically occurs when we leave the page containing the current applet • We can achieve this by calling stop() method • stop() method suspends applet execution until the user clicks on it 8
  • 9. Applet Life Cycle contd.. • Dead state • Applet is said to be dead when it is removed from memory. • This occurs by calling destroy() method • The destroy() method perform shutdown activities • It also removes the applet from the memory 9
  • 10. Applet Life Cycle contd.. • Display state • Applet moves to the display state whenever it has to perform some output operation on the screen • The paint() method is called to accomplish this task • Paint() method does absolutely nothing • We have to override this method to display the required graphics 10
  • 11. Summary In this class you, have learnt • Applet life cycle has different state – Born – Running – Idle – Dead 11
  • 12. Summary contd.. The method useful for these state change – init() – start() – stop() – paint() – destroy() 12
  • 13. Quiz 1. Which method in the life cycle of an applet called only once a) stop() b) start() c) init() d) destroy() 13
  • 14. Quiz contd.. 2. Which method in the life cycle of an applet removes the applet from the memory a) stop() b) start() c) init() d) destroy() 14
  • 15. Frequently Asked Questions 1. Write about the life cycle of an applet 15