Please send questions to st10@humboldt.edu .

CIS 480 - Spring 2001
HW #5
Due: Wednesday, March 28, 2001, END of lab

Remember the class style standards at the end of this handout...

Note that you need to write 2 distinct, different Java programs for
this assignment. (You MUST send AT LEAST 2 e-mails, with the Subject:
lines Hw5Num1.java and Hw5Num2.java.)

(We don't have the 90% credit + 10% for interesting this time...)

1. Consider the Java Swing application TestMenu.java, as given on Test #1's
problem 10. (I will not be making this available electronically --- you
will need to type it in.) You've got my messy notes about what you missed
on this on your answer key --- now actually correct your answer and get this
running, with a few additional modifications mentioned below.

FIRST: as a reminder, here is what you were to modify this code to do
on the test:

	(a) Cause it to expect a single command line argument --- if
	it does not get exactly one argument, it should complain about
	wanting exactly one argument, always, and it should exit
	without creating any GUI.

	(b) It should paint a message (initially in black) whose text
	is the given command-line argument at pixel location 50, 100
	in a panel placed in the center of the frame. (You may use the
	default font, or you may set the font --- your choice.)

	(c) Add an additional menu, Shades, that has two menu items
	Blue and Red. When one of the menu items is chosen, the color
	of the painted message should change to the color chosen.

SECOND: also make these additional modifications:
	
	(d) Name your resulting application Hw5Num1.java

	(e) Add an additional color of *your* choice (that is neither
	red nor blue nor black!) to your Shades menu.

	(f) Add *either* a Fonts or Size menu, your choice, with
	at least 3 Font choices as menu items or at least 3 size choices
	as menu choices. When chosen, the Font or size of the painted
	message should change accordingly. (Sure, you can do both if you
	want --- but only one of these is required.) You may choose
	whatever you'd like for the initial Font or Size.

2. Write an AWT GUI application or applet that makes use of 3 
additional threads specified below. 
	* You may choose to extend Thread or implement Runnable.

	* You must include your name somewhere inside your
	applet or application.
        
	* 1 thread must update a textfield with a running count;
        it must be updated no faster than once every 2 seconds.

        * 1 thread must change the background color of the applet or
        application, or of once of its major panels, no faster than
        every 10 seconds. (Switch between at least two different
	colors, or more if you prefer.)

        * 1 thread should repaint a shape or a line of text of
	your choice at different locations no faster than every 
	5 seconds. (Switch between at least two different locations, 
	or choose the locations randomly, or move it along a line
	hoizontally or vertically --- your choice.)

	* Provide two buttons that affect the textfield thread: 
	one "suspends" it, one "resumes" it. When it is resumed,
	the count should continue from where it left off.

	* You may lay all of this out in a pleasing manner of
	your choice.

	* Name your resulting application or applet Hw5Num2.java.

Minimal style standards (to be added to, if necessary!)
	*   If you want to "paint" using Swing components,
	use the guidelines as discussed in class and as demonstrated
	in the in-class examples.
	
	*   If your program involves gif files, either include
	them as attachments in a separate e-mail file with
	"Subject: [program name] images", OR include them on a web
	page using the tag:	<img src="YOUR_IMAGE.gif">
	and include the URL for this page in your opening comment
	block. 
	        *   The names of all required gifs, in either case,
		must be included prominently and neatly in the opening
		comment block, also.  

        *   Java GUI applications must always include 
	System.exit(0), and must handle window closing gracefully;

	*   Run-time exceptions (such as, but not limited to,
	NumberFormatExceptions) should be handled gracefully
	by proper use of try-catch blocks.

	*   Any applet (AWT or Swing) must include in
	its opening comment block its recommended size.

	*   every Java source file should begin with at least
	a small block comment describing the purpose of what
	is within, and including your name. If you are modifying
	existing code (such as an in-class example), you should
	indicate that, also.

	*   programs are expected to have at least a few
	descriptive internal comments

	*   neat, consistent indenting is required.

	*   reasonably-descriptive and non-misleading variable
	names are expected.

Then, send (at least) two e-mails to st10@humboldt.edu as follows:
        *   each Subject: line should be either:
                *   the name of Java source contained within that 
	        e-mail message, OR 

	        *   the required name of the Java source that 
	        would be contained there, if one program were not 
	        being used for several parts, OR

	        *   <required_java_source_name> images, if
	        it contains required image attachments.

        *   the *body* of the e-mail should contain either:
	        *   the Java source (NOT included as an attachment!),
		OR

		*   the name of the Java source to be graded
		for this part, also; OR,

		*   the image file(s), as attachments.

        *   please FIX the indenting in the Java source code
        if it is ugly when placed in the e-mail body! (Source code
        pasted from BlueJ sometimes requires such clean-up.)