The goal for this lab is to begin converting the system to graphics, including some color and pictures.

  1. At the end of today be sure to e-mail all work to your partner. This way each partner can review and press forward on the lab. Switch roles at the beginning of each lab.

  2. Decide which of your versions you'll work on and fix it up if necessary. Or you could use my versions of MainConversation, Conversation, and Ruler. Use my versions just to copy the boilerplate graphics code to your version, or you could download these and start fresh if you wish. You should probably download MainConversation in either case.

  3. Convert the system to a graphics system with a yellow background as we did in class. Set both the color and the size from inside Conversation. For the time being, the talking will still come to the black command window, but we have something graphic to look at.

  4. Remember the magic words for setting size: setPreferredSize(new Dimension(1100, 300));

  5. Add the import statements to Ruler and have Ruler extend JPanel just as Conversation does.

  6. Back in Conversation, after you create the Rulers we need to add them all to the graphics system. Write a separate routine, addRulers(), for this purpose. Since this code happens inside Conversation, just write something like add(rulerList[0]) to add the first ruler.

    • Of course you need to add them all, so do this in a loop. At this point you should see some indication that the Rulers are on the screen. They're not very impressive, but they're there.

  7. Give each ruler a different color. Follow the strategy from class. You can send a color to the Ruler upon creation via Color.green or Color.blue or something similar. Note that you are sending a Color, not a String. You will have to receive and save this in Ruler in a variable of type Color. Don't actually use the color right away, just save it. Use it in identify().

  8. Set the size in Ruler. A size of 500 X 300 should be big enough for now. Change the size settings in Conversation to accommodate your number of rulers in either two or three columns (you decide which). For example if you have six rulers, you might want the width to be a little over 1000 (two rulers wide) and the height to be at least 900 (three rulers high).

  9. Download some pictures for your rulers to the same directory as your code. It's best to get these from more than one site. In theory Java can work with just about any image format, but in practice it occasionally has trouble (particularly with bmp files). jpg and gif are the best file types for java. Getting the pictures from several sites ensures that most of them will work.

  10. Edit the pictures if necessary. We need the width and height to each be a max of maybe 200 pixels. You should be about here by the end of the first day. If not, try to get this done before next class. Wherever you get, be sure to e-mail the code and pictures to your partner.

  11. The next two steps will culminate in your images being added to the system.

  12. First, as in class, let's just get an image, hammock.gif, to show up. Using the file name, you need to declare and construct the ImageIcon object that will contain the picture while the program is running. Then you need to declare and construct a JLabel object that will display the image. Then you need to add the label to the Ruler panel.

  13. Once you have that working, you'll want to move some of the work to Conversation. In particular Conversation needs to tell each Ruler what its picture will be. You can either pass the file name as a String to Ruler and create the picture there (this is probably easier in the short run), or you can create the picture in Conversation and pass it to Ruler as an ImageIcon (probably better in the long run). I recommend doing the later even if you start with the former.

  14. Fix the code so that the picture doesn't actually show up until identify() is called.

  15. Clean up the code. This includes all the below:

    1. Make sure everything is up to date. All mirror and convenience functions, only two changes to add a ruler, all required routines, and so on.

    2. Add comments where needed. You already have a comment at the top of each class, but these might need updating now. You should have a comment on every routine, telling what the routine does (again existing ones may need updating). You should have a comment on pretty much every for loop and if structure. For example each separate if..else branch in report() should have a comment.

    3. Remove variables that aren't being used.

    4. Make all remaining variables private.

    5. Keep all the mirror and convenience functions in Ruler even if you aren't using them all right now.

    6. Be sure that names of variables and routines are well chosen. A good rule of thumb is nouns for variables (numConversations, lincoln), and verbs for routines (identify(), converse()).

    7.  Most routines should be public and it's OK to leave them all public for now.

  16. Make sure all your new code is properly documented.

  17. E-mail all three classes to your partner and to me, including time, date, and CSCI 151.