![]() ![]() ![]() |
Start of Tutorial > Start of Trail > Start of Lesson | Search |
Once you've written some code for your applet, you'll want to run your applet to test it. To run an applet, you first need to add the applet to an HTML page, using the<APPLET>
tag. You then specify the URL of the HTML page to your Java-enabled browser.
Note: Because you can't always rely on browsers to reload your applet's classes, you might want to use a quick-starting tool like the JDK Applet Viewer for most of your applet testing. Every time you change your applet, you can restart the Applet Viewer to make sure it loads all of the latest classes.Here's the simplest form of the
<APPLET>
tag:This tag tells the browser to load the applet whose<APPLET CODE=AppletSubclass.class WIDTH=anInt HEIGHT=anInt> </APPLET>Applet
subclass is named AppletSubclass. The following figure shows where the applet class file must be, relative to the HTML document that contains the<APPLET>
tag. As the figure shows, unless the applet is declared to be in a package, its class file should be in the same directory as the HTML file that has the<APPLET>
tag.When a Java-enabled browser encounters an
<APPLET>
tag, it reserves a display area of the specified width and height for the applet, loads the bytecodes for the specified Applet subclass, creates an instance of the subclass, and then calls the instance'sinit
andstart
methods.The
<APPLET>
tag has many options that you can use to customize your applet's execution. For example, you can put your applet's files into an archive. You can also specify parameters to be passed to the applet. These options are described in Using the APPLET Tag.
![]() ![]() ![]() |
Start of Tutorial > Start of Trail > Start of Lesson | Search |