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.

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

Fig. Fig. 3.2 3.2 Sample execution of the TicTacToe applet.<br />

Testing and Debugging Tip 3.3<br />

If the appletviewer command does not work and/or the system indicates that the appletviewer<br />

command cannot be found, the PATH environment variable may not be defined<br />

properly on your computer. Review the installation directions for the <strong>Java</strong> 2 Software<br />

Development Kit <strong>to</strong> ensure that the PATH environment variable is defined correctly for your<br />

system (on some computers, you may need <strong>to</strong> restart your computer after modifying the PATH<br />

environment variable). 3.3<br />

You are player X. To interact with the applet, point the mouse at the square where you<br />

want <strong>to</strong> place an X and click the mouse but<strong>to</strong>n (normally, the left mouse but<strong>to</strong>n). The applet<br />

plays a sound (assuming your computer supports audio playback) and places an X in the<br />

square if the square is open. If the square is occupied, this is an invalid move and the applet<br />

plays a different sound indicating that you cannot make the specified move. After you make<br />

a valid move, the applet responds by making its own move (this happens quickly).<br />

To play again, re-execute the applet by clicking the appletviewer’s Applet menu<br />

and selecting the Reload menu item (Fig. 3.3). To terminate the appletviewer, click<br />

the appletviewer’s Applet menu and select the Quit menu item.<br />

Reload the applet <strong>to</strong><br />

execute it again.<br />

Select Quit <strong>to</strong> terminate<br />

the appletviewer.<br />

Fig. Fig. 3.3 3.3 Selecting Reload from the appletviewer’s Applet menu.<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!