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).
(Thought Question: ) Why must you tell the browser the width and height of the area used for the applet?