When
an Applets is loaded, it undergoes a series of changes in its state as shown
below:
Initialization State:
An applet enters initialization state when it is first loaded. This is achieved
by calling the init() method of
applet class. The following operations are carried out in this state:
o Create
objects needed by the applet.
o Set
up initial values.
o Load
images or fonts.
o
Set up colors
publicvoid init()
{
……
……
}
Running State:
An applet enters running state when the system calls the start() method of applet class. This occurs automatically after the
applet is initialized.Starting can also occur if the applet is already in
‘stopped’ (idle) state. For example, one may leave a web page containing the
applet temporarily and return to the page later.
publicvoid
start()
{
……
……
}
Idle or Stopped State:
An applet becomes idle when it is stopped from running. Stopping occurs
automatically when one leave the page containing the running applet. It is also
done by calling stop() method. If
thread are used for running applets, then stop()
method must be called to terminate the thread.
publicvoid
stop()
{
……
……
}
Dead State:
An applet said to be dead when it is removed from memory. It occurs
automatically when we quit the browser. Destroying stage occurs only once in
the applet’s life cycle.destroy()
method is called in this state.
publicvoid
destroy()
{
……
……
}
Display State:
An applet moves to 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 in this state.
publicvoid
paint(Graphics g)
{
……
……
}
No comments:
Write comments