0% found this document useful (0 votes)
25 views

Java Applets

An applet is a Java program that can be embedded in a web page and runs in the browser. Applets are used to make websites more dynamic and interactive. All applets extend the Applet class. Applets are not standalone programs and run within a web browser or applet viewer. The init() method initializes variables and is called once at runtime. The start() method is called after init() and when returning to the page. The stop() method is called when leaving the page. The destroy() method is called when the browser shuts down and the paint() method repaints the applet.

Uploaded by

timmy
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Java Applets

An applet is a Java program that can be embedded in a web page and runs in the browser. Applets are used to make websites more dynamic and interactive. All applets extend the Applet class. Applets are not standalone programs and run within a web browser or applet viewer. The init() method initializes variables and is called once at runtime. The start() method is called after init() and when returning to the page. The stop() method is called when leaving the page. The destroy() method is called when the browser shuts down and the paint() method repaints the applet.

Uploaded by

timmy
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 12

1

Java Programming

Java Applet
Java Applet
2

What is Applet?

An applet is a Java program that can be embedded into a web page.

It runs inside the web browser and works at client side.

Applets are used to make the website more dynamic and entertaining.

All applets are sub-classes (either directly or indirectly)


java.applet.Applet class.

Applets are not stand-alone programs. Instead, they run within either a web
browser or an applet viewer. JDK provides a standard applet viewer tool
called applet viewer.
Java Applet
3

In general, execution of an applet does not begin at main() method.

Output of an applet window is not performed by System.out.println().


Rather it is handled with various AWT methods, such as drawString().
Java Applet
4
Java Applet
5
Java Applet
6

init( ) :

The init( ) method is the first method to be called. This is where you should
initialize variables. This method is called only once during the run time of
your applet.

start () −
This method is automatically called after the browser calls the init method. It
is also called whenever the user returns to the page containing the applet after
having gone off to other pages.

Stop() − This method is automatically called when the user moves off the
page on which the applet sits. It can, therefore, be called repeatedly in the
same applet.
Java Applet
7

destroy ()−

This method is only called when the browser shuts down normally. Because
applets are meant to live on an HTML page, you should not normally leave
resources behind after a user leaves the page that contains the applet.

paint ()−

Invoked immediately after the start() method, and also any time the applet
needs to repaint itself in the browser. The paint() method is actually inherited
from the java.awt.
Java Applet
8
Java Applet
9
Java Applet
10
Java Applet
11
Java Applet
12

You might also like