CSC 121A Lab 5 - Spring 2005

Thursday, February 3, 2005
Due: Wednesday, February 9, 2005, 5:00PM

[Course home page] [Java API Documentation]

Answer all numbered and bulleted questions. Upload your answers and program files to the VikingWeb coursework section. Besides uploading your written answers to the VikingWeb, please turn in a printed copy either in class on the due date or leave a copy in the box outside my door later on during the day. (You may turn in the printed copies later than 5PM on the due date, but the files must be uploaded to VikingWeb at or before 5PM.)

You may work in pairs for all parts of this assignment, including the homework exercises. Remember also, your code will be graded for robustness - i.e. how well it handles in cases of erroneous input, etc. Be sure to think about things that could go wrong and try to deal with them.

 

Sample Applets Provided with the Java SDK

The Java SDK comes with several demonstration applets and their source code. It can be interesting and helpful to read this source code if you want to learn new and exciting features of Java. We will not be doing anything further with these applets in this course, but you may want to browse the examples in the folder:

C:\Program Files\Java\jdk1.4.2\demo

(In general, the example files are in the demo directory of wherever you installed the Java SDK. The applets can also be accessed online at this site.)

To run the applets, either find the appropriate HTML file in the directory of the applet you wish to view and open it with the web browser. Or else, if Java is not installed in the web browser, or there are security restrictions on the browser, you can view the applets by running the appletviewer program from the terminal (command window).

For this lab, just try running the TicTacToe and DrawTest applets and take a brief look at their source code. You can look in detail at their source code and the other applets at your leisure.

 

Animation

Download the following program and image data files: LogoAnimator.java, LogoAnimatorJPanel.java, images.zip. (The images archive should be uncompressed into a directory named "images" in the same directory as the Java files.)

This program displays an animated logo by displaying a different image every 50 milliseconds, using the Swing Timer class. Run the program, look through the source code, then:

 

Applet Parameters

The HTML applet tag embedded in a web page has a way of specifying parameters for use by the applet. Within the <APPLET>...</APPLET> on can specify optional PARAM elements with a name and value. Look at the source for this web page and the corresponding applet code to see how this works: HelloApplet.html, HelloApplet.java. (To view the source of the web page, there is usually a menu command "View Source" somewhere under the "View" menu of your browser.

 

Simple Game Skeleton

The following files make up the skeleton for what could be developed into a simple arcade game.

Download, compile, and view the applet. A homework assignment (below) is left for you to exercise your creativity.

 

Homework Exercises

 

Based on material from Deitel & Deitel, Java How to Program, 6e.



Last modified: Wed Feb 2 21:18:05 EST 2005