Almost all the applets have graphical user interface (GUI).This page discusses few issues
which are particular to applet GUIs.
A D V E R T I S E M E N T
Applet is a Panel.
Since an Applet is a subclass of AWT Panel class, applets can contain other
Components, just as a Panel can contain. As Panels, Applets also do participate in
AWT drawing and the event hierarchy.
Applets do appear in the pre-existing browser windows.
This is having two implications. First, unlike GUI-based applications, applets dont
have to create the window to display themselves on. (They can do, if they have a good
reason, but usually they just display themselves within the browser window ).
Second, depending on browsers implementation, the applet's components may not be
shown unless an applet calls the validate() after adding components to itself.
Fortunately, calling validate() cannot hurt.
Each applet have a user-specified, pre-determined size.
Since the <APPLET> tag requires the applet's width and height to be specified, and
because browsers not necessarily allow applets to resize themselves, applets should make
with fixed amount of space that may not be ideal. Even if amount of space
is ideal for one platform, the platform-specific parts of applet (such as buttons)
may require a different amount of space on the other platform. You can do compensate by
recommending the pages that includes your applet specify a little more space than
be necessary, and by using the flexible layouts, like GridBagLayout and BorderLayout,
which adapt well to extra space.
Applets do load images using Applet getImage() methods.
An Applet class do provide a convenient form of getImage() which lets you to specify a base
URL as one argument, followed by second argument which specifies an image file
location, relative to base URL. The Applet getCodeBase() and getDocumentBase()
methods do provide the base URLs which the most applets use. Images that the applet always needs,
or needs to rely on a backup, are usually specified relative to where an applet's
code was loaded from. Images which are specified by an applet user
(often with the parameters in HTML file) are usually relative to page which includes
the applet (document base).
Applet classes and often the data files they use are loaded over the network,
Applets can perform several things to decrease the perceived startup time. Their Applet
subclass can be small one which immediately displays the status message. And, if some
of the applet classes or data are not used right away, the applet can preload classes
or the data by referencing them before they are needed. Cosider for example, the
AppletButton class, at the beginning of the main thread, gets the class object for the
window the button brings up. Here its main purpose is to make sure that the class is
valid, but an added benefit is getting the class object force the class file to be
loaded before it is needed, which makes the class instantiating much quicker than
if a class still had to be loaded.