A Presentation On Object Oriented Programming
Topic : LIFE CYCLE OF
APPLET
Presented By:
Richa Dasila.
160030101045
AMRAPALI INSTITUE OF TECHNOLOGY AND SCIENCES
CONTENTS:
Introduction.
Life Cycle.
Application.
Introduction:
 Java programs used in internet computing to respond the user.
 Applet=Java Byte Code + HTML page.
 They can be transported over the internet and can run using
AppletViewer / Web browser supporting java.
 Embedding Applets into web pages can be done via Local Applets or
Remote Applets .
 The Applet class is itself a subclass , the inheritance
may be better represented as:
java.lang.Object java.awt.Component java.awt.Container
java.awt.Paneljava.applet.Applet
 The Applet class uses the services of two classes namely, Applet and Graphics .
 Applet package provides life and behaviour to the applet through methods such
as init(), start() etc.
 Unlike other applications which call the main() method to execute the code .
When an applet is loaded java automatically calls a series of Applet class
method for starting,running and stopping thereby following a lifecycle.
Life Cycle:
Running
State
Idle
State
Dead
State.
Born
State
END.
BORN
STATE
init() :
This method is
used for
initialization
 Following Things can be done:
i. Objects can be created using Applet.
ii. Initial Values can be set.
iii. Colors can be set.
iv. Load fonts .
 This can be done only once in an applet’s life cycle.
BORN STATE.
 To provide any behaviour we must override the init() function.
 Syntax:
public void init()
{
………………..
…………..(Action)
…………………
}
RUNNING
STATE
start()
THE RUNING
STATE
 Applet enter this stage when :
 System calls the start() method of Applet class , this method is automatically called after
the init () .
 Applet is resumed from the idle stage after some activity by the user in different page.
• This method unlike init() can be called more than once , we may override the start()
method to create a thread to control applet.
 The syntax:
public void start()
{…………
……….(Action)
…………
}
 Applet moves to paint method to perform output operations on screen .
 This happens immediately after entering the running stage.
 The display stage is not considered as a part of applet’s life cycle .
 The default version of the display state does absolutely nothing.
 Syntax:
public void paint(Graphics g)
{……………
………(Action)
}
DISPLAY
STAGE
paint()
THE DISPLAY STAGE
IDLE
STATE stop()
THE IDLE STAGE:
 An Applet becomes idle when we leave the page containing the currently running
applet.
 If we use a thread to run the applet , we must use stop() method to terminate the
thread.
 We must override the stop() method.
 Syntax:
public void stop()
{………..
…..(Action)
……..
}
DEAD
STATE
destroy()
THE DEAD
STAGE
 Dead State = Removed from memory.
 This occurs automatically when we exit the browser
state.
 Invoking the destroy() method cleans up the
resources created by the applet.
 It can be overridden only once like the init() stage.
 Syntax:
public void destroy()
{
……………..
……(Action)
………….
}
APPLICATION:
 When we need something dynamic in the webpage :
Smart Presentation of statistical data.
 When we require flash outputs : Creative
presentation.
 Creating Remote Applets and storing them in the
internet for others to download and use.
Oops

Oops

  • 1.
    A Presentation OnObject Oriented Programming Topic : LIFE CYCLE OF APPLET Presented By: Richa Dasila. 160030101045 AMRAPALI INSTITUE OF TECHNOLOGY AND SCIENCES
  • 2.
  • 3.
    Introduction:  Java programsused in internet computing to respond the user.  Applet=Java Byte Code + HTML page.  They can be transported over the internet and can run using AppletViewer / Web browser supporting java.  Embedding Applets into web pages can be done via Local Applets or Remote Applets .
  • 4.
     The Appletclass is itself a subclass , the inheritance may be better represented as: java.lang.Object java.awt.Component java.awt.Container java.awt.Paneljava.applet.Applet
  • 5.
     The Appletclass uses the services of two classes namely, Applet and Graphics .  Applet package provides life and behaviour to the applet through methods such as init(), start() etc.  Unlike other applications which call the main() method to execute the code . When an applet is loaded java automatically calls a series of Applet class method for starting,running and stopping thereby following a lifecycle.
  • 6.
  • 7.
    BORN STATE init() : This methodis used for initialization  Following Things can be done: i. Objects can be created using Applet. ii. Initial Values can be set. iii. Colors can be set. iv. Load fonts .  This can be done only once in an applet’s life cycle. BORN STATE.
  • 8.
     To provideany behaviour we must override the init() function.  Syntax: public void init() { ……………….. …………..(Action) ………………… }
  • 9.
    RUNNING STATE start() THE RUNING STATE  Appletenter this stage when :  System calls the start() method of Applet class , this method is automatically called after the init () .  Applet is resumed from the idle stage after some activity by the user in different page. • This method unlike init() can be called more than once , we may override the start() method to create a thread to control applet.
  • 10.
     The syntax: publicvoid start() {………… ……….(Action) ………… }
  • 11.
     Applet movesto paint method to perform output operations on screen .  This happens immediately after entering the running stage.  The display stage is not considered as a part of applet’s life cycle .  The default version of the display state does absolutely nothing.  Syntax: public void paint(Graphics g) {…………… ………(Action) } DISPLAY STAGE paint() THE DISPLAY STAGE
  • 12.
    IDLE STATE stop() THE IDLESTAGE:  An Applet becomes idle when we leave the page containing the currently running applet.  If we use a thread to run the applet , we must use stop() method to terminate the thread.  We must override the stop() method.  Syntax: public void stop() {……….. …..(Action) …….. }
  • 13.
    DEAD STATE destroy() THE DEAD STAGE  DeadState = Removed from memory.  This occurs automatically when we exit the browser state.  Invoking the destroy() method cleans up the resources created by the applet.  It can be overridden only once like the init() stage.
  • 14.
     Syntax: public voiddestroy() { …………….. ……(Action) …………. }
  • 15.
    APPLICATION:  When weneed something dynamic in the webpage : Smart Presentation of statistical data.  When we require flash outputs : Creative presentation.  Creating Remote Applets and storing them in the internet for others to download and use.