![]() |
< Day Day Up > |
![]() |
13.4 Java AppletsA 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.)![]() In the end, Applets didn't make as big a splash on Web pages as industry forecasters originally thought. One of Java's limitations is that its applets don't work unless a Web page visitor has a special software program called a Java Virtual Machine. This program translates the Java code into instructions appropriate for the visitor's particular operating system. As with plug-ins, virtual machines require lengthy downloads and installations that scare off many potential users. In addition, unlike JavaScript, which is fairly easy to learn, Java is not for the faint of heart. It's a complex language that requires a lot of skill and practice to do well. 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 Insert 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 PropertiesYou 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?" In the Properties inspector for a Java applet, a new Parameters button appears.![]() |
![]() |
< Day Day Up > |
![]() |