Java Reference
In-Depth Information
When using appletviewer , keep in mind that it provides the window frame. Applets run
in a browser will not have a visible frame.
Let's review an applet's key points:
All AWT-based applets are subclasses of Applet .
Applets do not need a main( ) method.
Applets must be run under an applet viewer or a Java-compatible browser.
User I/O is not accomplished with Java's stream I/O classes. Instead, applets use the
interface provided by a GUI framework.
Applet Organization and Essential Elements
Although the preceding applet is completely valid, such a simple applet is of little value.
Before you can create useful applets, you need to know more about how applets are organ-
ized, what methods they use, and how they interact with the run-time system.
The Applet Architecture
As a general rule, an applet is a GUI-based program. As such, its architecture is different
from the console-based programs shown in the first part of this topic. If you are familiar
with GUI programming, you will be right at home writing applets. If not, then there are a
few key concepts you must understand.
First, applets are event driven, and an applet resembles a set of interrupt service routines.
Here is how the process works. An applet waits until an event occurs. The run-time system
notifies the applet about an event by calling an event handler that has been provided by the
applet. Once this happens, the applet must take appropriate action and then quickly return
control to the system. This is a crucial point. For the most part, your applet should not enter
a “mode” of operation in which it maintains control for an extended period. Instead, it must
perform specific actions in response to events and then return control to the run-time sys-
tem. In those situations in which your applet needs to perform a repetitive task on its own
Search WWH ::




Custom Search