|< Day Day Up >|
13.4 Java Applets
A few years ago, it seemed that the whole world was going Java crazy. Created by Sun Microsytems, this powerful programming language seemed to offer an end to crossplatform problems. Programs written in Java can run on any operating system: Mac, Unix, Windows, whatever. Java also offered programmers the opportunity to write sophisticated applications that could run in the form of a compact file, called an applet, within any browser. Java applets can provide sophisticated graphics and user interface elements that go well beyond what HTML can do (Figure 13-8). In fact, Java can be used not only for graphics and multimedia, but to build complete applications like word processors, spreadsheets, or mortgage calculators that can live right in a Web page. For loads of sample applets, visit www.javaboutique.com .
In this example, a Java applet lets you interactively determine whether your body mass is appropriate for your age and height. Through the use of custom interface elements (such as the sliders under the height and weight columns), you control the size of the "man" and receive instant feedback in various form fields. (In this example, only the area between the two horizontal rules is the actual applet. Everything else is HTML.)
But when the time comes that you've been handed a Java applet for insertion onto, say, a client's page, here's how to do it.
To insert a Java applet, choose InsertMediaApplet, or choose Applet from the Media menu on the Common tab of the Insert bar. When the Select File dialog box appears, find and double-click the Java applet file you want to insert. (Java applets have a .class or .jar extension.)
After you insert it, the applet appears on your Web page as a gray box with a coffee cup logo in the middle. Unfortunately, you can't preview it within Dreamweaver; press the F12 key to see it run in your Web browser.
13.4.1 Applet Properties
You set properties for applets using the Property inspector (see Figure 13-9), just as for any HTML object. The name, margins, alignment, and width/height controls work just as they do for Flash movies (see Section 13.1.2). Java applets, however, offer a few specialized controls:
Some applets may have properties in addition to the ones listed in the Property inspector. To add these properties, click the Parameters button. For example, the applet ticker.class shown in Figure 13-9 produces a ticker-tape display on a Web page. In order to let the applet know what message it needs to present, you must add a parameter called message. The value of that parameter would be the message: "Welcome to my home page. This ticker-tape display is truly annoying, isn't it?"
|< Day Day Up >|