Java Reference
In-Depth Information
These lifecycle methods are typically overridden by applet classes. For
example, if an applet uses a thread to do its work,
init
would typically
create the thread;
start
would invoke the thread's
start
method the first
time and ask it to continue execution on subsequent invocations;
stop
could ask the thread to pause to prevent it from consuming resources
while the page is not visible; and
destroy
could interrupt the thread be-
cause the thread would no longer be needed.
An applet can get parameters from a
<param>
tag to customize its beha-
vior. It might get colors, fonts, or the
URL
of an image to display.
Applets usually run in a highly constrained security environment to pro-
tect your computer and network from unwelcome inspection or invasion
by a hostile applet. This means that certain conveniences, such as a loc-
al scratch disk, may not be available by default. You can grant permis-
sion to perform particular actions to individual applets by specifying an
appropriate security policy.
The applet model is a good example of how the Java platform provides
power. The fact that the same code runs on all systems in the same way
allows a single piece of code (an applet) to run in a variety of browsers
on a variety of windowing systems running on a larger variety of oper-
ating systems. The portability of Java bytecodes allows you to execute
part of your application on the server and another part on the client
system via downloaded code, whichever is appropriate. It is the same
platform on both sides: the Java virtual machine. The ability to move
code from one place to another and execute it in a secure environment
enables new ways of thinking about where to execute what part of your
design.