Java Reference
In-Depth Information
• An applet cannot make network connections except to the host that provided
the applet.
• An applet cannot invoke any program on the host executing the applet.
These are limitations not placed on Xlets, making the applet execution model more
desirable in the context of providing backward compatibility with existing applets or
offering a robust web browsing experience than in the context of providing an applica-
tion execution environment for new applications.
Like Xlets and MIDlets, applets have a life cycle enforced through the interface pro-
vided by the base class, java.applet.Applet . An applet context accompanies a running
applet, permitting applets access to resources such as sounds, images, and other applets
running within the same context.
Looking at the Applet Life Cycle
Figure 10-1 shows the states an applet passes through during its execution. Unlike Xlets
and MIDlets, an applet cannot pause execution; instead, the applet execution environ-
ment can stop or start an applet. Specifically, the runtime can perform the following
actions:
• Create the applet, invoking the applet's constructor.
• Give the applet an opportunity to initialize by invoking its init method.
• Start the applet by invoking its start method.
• Stop the applet when it loses focus, such as when a browser navigates to a different
page, by invoking its stop method.
• Restart the applet (possibly reloading and reinitializing it) when the applet regains
focus by invoking start again.
• Stop the applet and give it an opportunity to perform any final cleanup by invoking
its destroy method before garbage collecting the applet. Of course, an applet can
be destroyed at any other time, too.
 
Search WWH ::




Custom Search