This first project was for fun, displaying an aquarium full of fish swimming around using multithreaded sprite animation. What could be more fun than a dozen bright green guppies floating around on your computer? It's suitable when you need a quick break from work, as a backdrop on your desktop, something to perk you up, or just anytime you need an aquarium.
This application used a fair number of sophisticated techniques in order to get its fish to swim. The fish images are GIF files specially created with transparent areas to make sure they look like fish swimming around, not small white boxes. The MediaTracker object in this application read in the fish images and stored them as graphics sprites. The sprites were animated with a new thread, which the application took care to end when the main window was closed. The fish were implemented as objects, and each knows how to swim around the tank as well as when to bounce off the edges, as required. Also, the application took care of flickering by using double buffering.
The result of all this work was a pleasing aquarium application. The coming chapters will get into more powerful applications, of courseInternet intercoms, chat rooms, online JPEG factories, and so on, but it doesn't hurt to start with a little fun.