ptg7068951
44 HOUR 4:Understanding How Java Programs Work
The appletviewer tool is useful for testing, but it gives the wrong impres-
sion about applets. They don’t run in their own windows as Java applica-
tions. Instead, they’re placed on web pages as if they are text, photos, or
graphics. The applet is presented seamlessly with the rest of the page.
Figure 4.3 shows RootAppleton a web page. The applet window is the
white box that displays the program’s output: the square root of 225. The
heading, paragraphs of text and lightbulb photo are ordinary elements of a
web page.
Java applets can be static like the output of this project, but that’s a com-
plete waste of the language. Applets usually display dynamic content as in
a stock ticker, chat room client, or video games.
FIGURE 4.2
TheRootAppletapplet running in
appletviewer.
FIGURE 4.3
TheRootAppletapplet on a web
page loaded in the Google Chrome
browser.