You need to write an applet.
Write a class that extends
javax.swing.JApplet, and use some or all of the
applet methods. Start with
Applet if you want to
AWT and be portable to all browsers; use
JApplet if you want Swing
capabilities in your applet (but see the note at the end of this
recipe under Section 17.3.4).
cycle” methods that an applet writer can implement are
stop( ), and
destroy( ) (see
Table 17-2). The applet’s life cycle is more
complex than that of a regular application, since the user can make
the browser move to a new page, return to a previous page, reload the
current page, etc. What’s a poor applet to do?
Table 17-2. Applet methods
Initialize the applet (takes the place of a constructor).
The page is loaded, and we’re ready to display.
The user is leaving this page.
The applet is being unloaded.
Applets normally use their
init( ) method to
state, the same functionality as a
constructor in a non-applet class. This may seem a bit odd for those
used to constructors in an OO language. However, it is mandatory for
any methods that will call applet-specific methods, such as the
getParameter( ). Why? In brief,
browser will first construct the applet -- always with the no-argument constructor form, which is much easier for the browser (see ...