An applet is a "little application" that can be run in the context of a web page.
An applet is an object whose methods are
run under the control of a web browser.
The web browser acts as a
main() method and
calls the applet's methods.
The methods are called
when a web page containing an applet is loaded,
or in response to events such as mouse clicks
or menu selections.
Applets do not run by themselves. They are run in the context of a web browser or the appletviewer of the JDK.
To include an applet on a web page use the following set of tags:
<applet code="MyApplet.class" width="250" height="200"> </applet>
height give the size of
a rectangle in the web browsers screen that will be used
for the applet.
You cannot omit
you can pick any reasonable values you want.
code="MyApplet.class" part names the
compiled bytecodes of the applet that will be run.
With the above form of the
the bytecodes must be in the same disk subdirectory
as the web page.
(For details on how to create applets and how to compile them,
see Part 5 of these Notes).