Web pages are basically of two types – static and dynamic
web pages. Applets are basically used to create dynamic pages. Using HTML we
can create only static pages, not dynamic pages. So Java using applet is used
to create dynamic pages. There are two types of classes for applet – Applet
class and Graphic class. The difference of an applet program from a normal
program is that it does not contain the main function (though it can contain
main function). So it has no entry point. The program starts executing from
some functions present in Applet class. Secondly, an applet program cannot be
executed independently as done in case of normal application programs. They
must be executed with the help of either applet viewer or with the help of any
web browser. If using an applet viewer to run a program, we just need to write
the following syntax.
Listing 1
When we want to execute an applet program with the help of a
web browser, we need to write an HTML file. This file must contain an applet
tag. An example of such a file is shown below.
Listing 2
<html>
<head>
<title>
A Simple Example of Applet
</title>
<body>
<applet code ="filename.class" width =“100px” height =“100px”></applet>
</body>
</html>