***Jim's Sample Solution***

Double Expresso--make it thick...

Due Date: Thursday November 11, 1999 at start of class.

Assignment:
A partially written applet and an html file are available for you to use. You can get them from the intront server or from the course volume. The path is:

/afs/andrew.cmu.edu/course/15/119/handouts/lab12

The files are called Lab12.java and Lab12.html. You should ftp these as ascii. You should compile the .java file, run the applet, and see how the applet works before you begin to add the modifications required. Notice that button 1 is already installed and working but it just draws circles. You will have to replace these circles with your monogram.

Using these files as a start, write a Java applet that has five buttons. There will be NO layout managers or panels used in this lab Flow layout is required. Each button will cause a different pattern of your monogram to be drawn across the screen. Monograms may be tangent to each other but may not overlap except as noted below.
- Button 2 should display a vertical line of monograms on the left side of the window extending from the top to the bottom. No partial monograms are allowed.
- Button 3 should cause a frame of monograms to be drawn along the top, down the right, across the bottom and up the left sides of the widow. Monograms can overlap only at the corners. No partial monograms are allowed.
- Button 4 should draw a full screen of monograms - neat rows of monograms starting at the top and going to the bottom with each row extending from the left side to the right side. There must be no overlapping and no partial monograms.
- Button 5 should draw a diagonal line from the upper left corner towards the lower right corner of the window. The line must stop when either the bottom or right side of the window is reached - the line does not have to go to the actual corner. There must be no partial monograms.

Background:
You will have to get the dimensions of the window since the user can change it and your program must still meet the specifications. One of the methods in the applet does this using a Dimension object called dim. This will be discussed in class.

Handin:
Use the same routine as in previous labs.


15-119 Fall 99                                                                  Lab 12

Back to 15-119 Assignments