|
|
|
|||
|
Running Swing AppletsThis section describes how to run applets that use Swing components. For information on writing Swing applets, see How to Make AppletsYou can run Swing applets in any browser that has the appropriate version of Java Plug-in installed. Other options are to use a JDK 1.1-compliant browser that can find the Swing classes, or to use a 1.2-compliant browser. Currently, the only 1.2-compliant browser available is the Applet Viewer utility provided with JDK 1.2. For information on setting up 1.1-compliant browsers to work with Swing, see Make Your Browser Swing, an article in The Swing Connection.
To test whether your browser can run applets,
go to
![]() This is a picture of the applet's GUI. To run the applet, click the picture. The applet will appear in a new browser window. HelloSwingApplet.java,
and the HTML code for including the applet
by viewing the HTML source for
HelloSwingApplet.html.
The bad news is that the HTML code for including the applet
is rather convoluted.
The good news is that you can generate the HTML code automatically
from a simple <APPLET> tag.
See the
Java Plug-in documentation
for details on downloading a free HTML converter.
Here is a more complex applet, which uses multiple class and image files. ![]() This is a picture of the applet's GUI. To run the applet, click the picture. The applet will appear in a new browser window. AppletDemo.java.
It uses the files
images/right.gif,
images/middle.gif,
and
images/left.gif
as well.
The rest of this section gives step-by-step instructions
for running the preceding applets.
For information on writing applets,
see
How to Make Applets Step by Step: Running a Swing-Based Applet
| |||
|