As the final exercise for this chapter, you will build a critter program that has a graphical interface. This program will look and feel more like the programs you encounter on the Windows operating system. As usual, an image or two of the program is more helpful than just a description. Figure 6.1 demonstrates the Visual Critter in its default state.
You can see from Figure 6.1 that the newest version of the critter has much more visual appeal than the older versions. Modern users have become used to the convenience of a graphical interface, with all the various components such as text boxes, scroll bars, and command buttons. This version of the Visual Critter features several standard graphical controls.
Before diving into how all these controls work, you should play around with the program and see what it does. This is a highly interactive program, so you should open it from the CD-ROM and look at it live. I’ll show you a few of the highlights now in case you aren’t near a computer.
Figure 6.2 demonstrates what happens when you click the critter image.
I have attached code to the image so that when it is clicked, a message appears. The critter asks the user to change the critter’s name. Take a look at Figures 6.3 and 6.4 to see how the user can edit the name in the rectangle on the left side of the form.
You can do other interesting things with the critter. You can change its mood by clicking the drop-down list of various temperaments. Figure 6.5 illustrates the critter after the user chooses a different mood.
The user can also change the critter’s size, by manipulating the scroll bar. Changing the location of the rectangle inside the elevator shaft changes the size of the critter image. Figures 6.6 and 6.7 illustrate this phenomenon.
You can also change the color of the background on which the critter resides. Illustrating these color changes on a black-and-white page is impossible, so you need to experiment with the program to see this phenomenon.
3.135.191.86