The goal for this two day lab is to begin converting the system to graphics, including some color and pictures.
This lab will spread over two class days. At the end of day 1 be sure to e-mail all work to your partner. This way if you miss class next time your partner can carry on. Switch roles at the beginning of each lab. Note that even if you finish the lab early, you should come to class each day.
Decide which of your versions you'll work on and fix it if necessary. Here are text versions of MainConversation, Conversation, and Ruler. You could use these just to copy the boilerplate graphics code to your version, or you could start fresh with these if you wish.
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 see.
Remember the magic words for setting size: setPreferredSize(new Dimension(1100, 300));
Add the import statements to Ruler and have Ruler extend JPanel just as Conversation does.
Back in Conversation, after you create the Rulers we need to add them all to the graphics system. Write a separate method, 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.
Give each ruler a different color. Follow the same strategy used for the other ruler characteristics. You can send a color to the Ruler upon creation via Color.green or Color.blue or something similar. See page 140 or the online documentation for a list of predefined colors.
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).
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). The best file types for java are jpg and gif. Getting the pictures from several sites ensures that most of them will work.
Edit the pictures if necessary. We need the width and height to each be a max of maybe 125 pixels. You should be about here by the end of the first day. If not, try to get this done before next class. No matter how much you complete, be sure to e-mail the code (always send .java files) and pictures to your partner. Only send me the files when you finish.
The next two steps will culminate in your images being added to the system.
First let's just get an image, hammock.gif, to show. 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.
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 then create the picture in Ruler or send the alreay created picture. I recommend creating the picture as an ImageIcon in Conversation at the same time you are passing it to Ruler. Hint: new ImageIcon(filename) is a valid parameter.
Fix the code so that the picture doesn't actually show up until identify() is called (runs or is executed).
Make sure all your new code is properly documented/commented.
E-mail all three classes (always send .java files) and the snippet/picture of the results window to your partner and to me, including CSCI 151, time, date, and subject.
Show the results and the code.
Upload all three .java files and the snippet of the results to Blackboard as a backup.