26.07.2013 Views

Java How to Program Fourth Edition - DCC

Java How to Program Fourth Edition - DCC

Java How to Program Fourth Edition - DCC

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 3 Introduction <strong>to</strong> <strong>Java</strong> Applets 109<br />

Example Description<br />

DrawTest Allows the user <strong>to</strong> drag the mouse <strong>to</strong> draw lines and points on the applet in<br />

different colors.<br />

Fractal Draws a fractal. Fractals typically require complex calculations <strong>to</strong> determine<br />

how they are displayed.<br />

GraphicsTest Draws a variety of shapes <strong>to</strong> illustrate graphics capabilities.<br />

GraphLayout Draws a graph consisting of many nodes (represented as rectangles) connected<br />

by lines. Drag a node <strong>to</strong> see the other nodes in the graph adjust on<br />

the screen and demonstrate complex graphical interactions.<br />

ImageMap Demonstrates an image with hot spots. Positioning the mouse pointer over<br />

certain areas of the image highlights the area and a message is displayed in<br />

the lower-left corner of the appletviewer window. Position over the<br />

mouth in the image <strong>to</strong> hear the applet say “hi.”<br />

JumpingBox Moves a rectangle randomly around the screen. Try <strong>to</strong> catch it by clicking it<br />

with the mouse!<br />

MoleculeViewer Presents a three-dimensional view of several different chemical molecules.<br />

Drag the mouse <strong>to</strong> view the molecule from different angles.<br />

NervousText Draws text that jumps around the screen.<br />

SimpleGraph Draws a complex curve.<br />

SortDemo Compares three sorting techniques. Sorting (described in Chapter 7)<br />

arranges information in order—like alphabetizing words. When you execute<br />

the applet, three appletviewer windows appear. Click in each one<br />

<strong>to</strong> start the sort. Notice that the sorts all operate at different speeds.<br />

SpreadSheet Demonstrates a simple spreadsheet of rows and columns.<br />

SymbolTest Draws characters from the <strong>Java</strong> character set.<br />

TicTacToe Allows the user <strong>to</strong> play Tic-Tac-Toe against the computer.<br />

WireFrame Draws a three-dimensional shape as a wire frame. Drag the mouse <strong>to</strong> view<br />

the shape from different angles.<br />

Fig. Fig. 3.1 3.1 The examples from the applets direc<strong>to</strong>ry (part 2 of 2).<br />

Change direc<strong>to</strong>ries <strong>to</strong> subdirec<strong>to</strong>ry TicTacToe. In that direc<strong>to</strong>ry you will find the<br />

HTML file example1.html that is used <strong>to</strong> execute the applet. In the command window,<br />

type the command<br />

appletviewer example1.html<br />

and press the Enter key. This executes the appletviewer. The appletviewer loads<br />

the HTML file specified as its command-line argument (example1.html), determines<br />

from the file which applet <strong>to</strong> load (we discuss the details of HTML files in Section 3.3) and<br />

begins executing the applet. Figure 3.2 shows several screen captures of playing Tic-Tac-<br />

Toe with this applet.<br />

© Copyright 1992–2002 by Deitel & Associates, Inc. All Rights Reserved. 7/2/01

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!