ptg7068951
242 HOUR 17:Creating Interactive Web Programs
When you run the applet in a browser, you might be asked whether it’s
OK to run the program. Many web browsers must be configured to enable
Java programs before they run Java applets.
Java applets are run in current browsers by the Java Plug-in, an interpreter
from Oracle that supports the most up-to-date version of the language.
Aplug-inis a program that works in conjunction with a web browser to
expand its functionality. Plug-ins handle a type of data that the browser
normally could not handle. Apple offers a plug-in to display QuickTime
movies, Macromedia distributes a plug-in to run Flash animation files, and
many other kinds of special content are supported in this manner.
The plug-in can be downloaded from Sun’s Java site at http://www.java.com.
Sending Parameters from a Web
Page
The functionality of an applet can be customized with the use of parame-
ters, settings stored in HTMLmarkup that serve the same purpose as com-
mand-line arguments in applications.
Parameters are stored as part of the web page that contains an applet.
They’re created using the HTMLtag paramand its two attributes: nameand
value. You can have more than one paramtag with an applet, but all must
be placed between the opening <applet>and closing </applet>tags.
Here’s an applettag that includes several parameters:
FIGURE 17.1
TheSalutonAppletapplet loaded
with Microsoft Internet Explorer.
TIP
NetBeans can test applets with-
out the necessity to create a
web page. With the applet’s
class file open in the source
editor,choose the menu com-
mand Run,Run File. The applet
is loaded by the appletviewer
tool,which is part of the Java
Development Kit (JDK).