VIPS OOPS Unit 3 Applet
VIPS OOPS Unit 3 Applet
import java.lang.Object
import java.awt.Component
(implementsjava.awt.image.ImageObserver,java.awt.MenuCont
ainer,java.io.Serializable)
import java.awt.Container
import java.awt.Panel
import java.applet.Applet
Applet Statements
• This applet begins with two import statements.
The first imports the Abstract WindowToolkit (AWT) classes.
Applets interact with the user (either directly or indirectly) through the AWT,
not through the console-based I/O classes.
Abstract Windowing Toolkit AWT
Earlier versions of Java
Applet class is one of the AWT components
Java Foundation Classes JFC
Extension to Java in 1997
Has a collection of Swing components for enhanced GUIs
Swing component classes begin with J
Life Cycle of Applet
Applet method
public void init () Also:
public void start () public void repaint()
public void stop () public void update (Graphics)
public void destroy () public void showStatus(String)
public void paint (Graphics) public String
getParameter(String)
Life Cycle of Applet
Life Cycle of Applet consists of four phases:
1. Applet Initialized:Objects regarding Applet get initialized in this phase. An init() method is called for the
same purpose.
2. Applet Running:Applets are embedded in a webpage. When a part of webpage which consists of applet is
shown on a screen, then applet is in Running phase. A start() method is called, which takes applet to the
Running phase.
4. Applet Destroyed:When you closed the webpage which consists of applet, applet is get destroyed. A
destroy() method is called when applet is destroyed.
public void init()
public void paint(Graphics g): is used to paint the Applet. It provides Graphics class object
that can be used for drawing oval, rectangle, arc etc.
Q Who is responsible to manage the life cycle of an applet?
Java Plug-in software.