0% found this document useful (0 votes)
2 views11 pages

Understanding Java Applets and Their Lifecycle

An Applet is a client-side program embedded in webpages to create dynamic content, offering advantages like reduced response time and cross-platform compatibility. The Applet life cycle includes stages such as initialization, running, stopped, and destroyed, with key methods like init(), start(), paint(), stop(), and destroy() defining its behavior. Applets can be classified as Local Applets, which are stored on the user's computer and do not require internet access, or Remote Applets, which are stored on remote servers and require internet connectivity to access.

Uploaded by

venkata rajesh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views11 pages

Understanding Java Applets and Their Lifecycle

An Applet is a client-side program embedded in webpages to create dynamic content, offering advantages like reduced response time and cross-platform compatibility. The Applet life cycle includes stages such as initialization, running, stopped, and destroyed, with key methods like init(), start(), paint(), stop(), and destroy() defining its behavior. Applets can be classified as Local Applets, which are stored on the user's computer and do not require internet access, or Remote Applets, which are stored on remote servers and require internet connectivity to access.

Uploaded by

venkata rajesh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Q) what is Applet ?

Applet is a special type of program that is embedded in the webpage to


generate the dynamic content. It runs inside the browser and works at client
side.

Advantage of Applet
There are many advantages of applet. They are as follows:

o It works at client side so less response time.

o Secured

o It can be executed by browsers running under many plateforms, including


Linux, Windows, Mac Os etc.

……..END…

Q)Applet Life Cycle ?

It is derived from the Applet class. When an Applet is created, it goes through
different stages; it is known as applet life cycle.

1. Born or initialization state


2. Running state
3. Stopped state
4. Destroyed state
5. Display state

Applet Life Cycle Methods

1. init ( )
The init( ) method is responsible for applet initialization when it is loaded. It is
called by browser or applet viewer only once.
Syntax

public void init( )


{
//actions
}

2. start ( )
It is invoked after the initialization state and applet entered into running state.
It starts the execution of Applet and the applet becomes an active state.

Syntax

public void start()


{
//actions
}

3. paint( )
This method is used to display output on screen. It takes [Link]
object as a parameter. It helps to create Applet GUI such as a colored
background, drawing etc.

Syntax

public void paint(Graphics g )


{
//Display statement
}

4. stop( )
This method is responsible to stop the execution and applet becomes
temporarily inactive state. It is invoked when Applet is stopped.
Syntax

public void stop( )


{
//actions
}

5. destroy( )
It destroys and removes the applet from the memory. It is invoked only once.
This is end of the life cycle of applet and it becomes dead.

Syntax

public void destroy()


{
//actions
}

…….END….

Q)Local Applet and Remote Applet ?

We can be classified the java applets into two ways –


• Local Applet

• Remote Applet

Local Applet
An applet developed locally and stored in a local system that is known as a Local
Applet. When a web page is trying to find a local applet, it doesn’t need to use the
Internet and the local system doesn’t require the Internet Connection.
Remote Applet
A remote applet is that which is developed by someone else and stored on a
remote computer connected to the Internet. If our system is connected to the
Internet, we can download the remote applet onto our system via the Internet.

Local Applet Remote Applet


1. Local Applet is 1. Remote Applet is
stored on our not stored on our
computer. computer.

2. It is not required 2. It is required


Internet Connection Internet Connection
to access the applet. to access the applet.

3. In a local applet, it 3. In a remote applet,


don't need the it needs the applet's
applet's URL. URL.

…………END….

You might also like