Java Reference
In-Depth Information
Chapter 12
Applets
Learning Objectives
After reading this chapter, you should:
￿ know what applets are and how they are used;
￿ be aware of the internal sequence of method invocations that occurs when an
applet is executed;
￿
know how to use images applets;
￿
know how to use sound in applets.
As was mentioned at the start of the last chapter, Java applets were responsible for
much of the initial popularisation of the Java language. This is because Java was
introduced at a time when the World Wide Web was in its infancy and needed a
platform-independent language in order to achieve its full potential. Java, through
its applets, satisfi ed this need. This led to a large number of users thinking of Java
entirely in terms of applets for the fi rst few years of the language's existence. Indeed,
many of the early Java authors covered Java exclusively or very largely in terms of
applets. As the reader who has worked through the preceding 11 chapters of this
topic cannot fail to appreciate, there is far, far more to Java than just applets. In fact,
what can be done with applets is only a subset of what can be done with Java appli-
cations, largely due to security restrictions that are placed on applets. However, this
does not mean that Java applications can be used to replace applets. What, then, are
applets?
Java applets are programs designed to be run from HTML documents by Java-
aware Web browsers. They are server-side entities that need to be downloaded
and run by the user's Web browser when the HTML documents (the Web pages)
encapsulating them are referenced This being the case, it is important that the user
is not discouraged from accessing the associated Web pages by irritatingly long
download times. Consequently, applets are usually very small programs performing
very specifi c tasks. Unlike a Java application, an applet must have a GUI, because
it always runs in a graphical environment.
Search WWH ::




Custom Search