Chapter 17: Final Project


You made it! With the presentation on event handling in the previous chapter, you have finished your from-the-ground-up introduction to the Java programming language. You now know a lot about Java, and in this chapter you'll prove it. You will observe the development of a substantial programming project, and it will all make sense. The project will draw on the information you learned in every other chapter of this book. It includes a GUI that paints, uses components, and sends out events. Classes will be extended and interfaces will be implemented. Exceptions will be thrown and caught.

This chapter doesn't just walk you through a finished, polished program. That would be like dissecting an animal in high-school biology class. Seeing something grow and develop is better than studying something that's dead. So for each piece of the project, you will see not just the final product, but also the living process that culminates in the finished, polished program.

Description of the Project

We will create a GUI that displays Java source code in an easy-to-read format. The user will be able to choose any .java file. Most of the code will appear in black letters, but line comments and Java keywords will appear in different colors, to be specified by the user.

Figure 17.1 shows the application in action. It is displaying one of the source files of the project.

click to expand
Figure 17.1: Final Project

The Show lines check box draws horizontal lines to make the text more readable. Figure 17.2 is the same code, with lines.

click to expand
Figure 17.2: Final Project, with lines

The black-and-white figures don't communicate the dramatic effect of multicolored source code.

Now is a good time to run the actual project code, so you can get familiar with what you'll be doing in the rest of this chapter. Type java fancysrc.FancySrcFrame. You'll see the GUI controls shown in the figures, above a blank display area. To display some code, select Open… in the File menu. You will see a file chooser. Use the chooser to select one of the source files on the CD-ROM, or one of your own Java source files.

Now let's get to work.




Ground-Up Java
Ground-Up Java
ISBN: 0782141900
EAN: 2147483647
Year: 2005
Pages: 157
Authors: Philip Heller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net