Read an Excerpt
PREFACE: Programmers working with Java typically don't have to write very much code before they're knee deep in the Abstract Window Toolkit (AWT). And when they're knee deep, they may start to look around for a helping hand.
In general, the goal of Graphic Java is to provide that helping hand.
The way we do that is twofold:
We describe practical use of the AWT, highlighting features, benefits, and gotchas and unraveling its mysteries as we go along.
We describe extending the AWT, focussing on a set of high-level custom components we've developed and packaged as the Graphic Java Toolkit.
We'd like to emphasize use of the Graphic Java Toolkit. In many ways, Graphic Java is not just a book with an accompanying CD. It is a product with an accompanying book. The Graphic Java Toolkit is a fully developed, fully tested, and fully documented product, and we think you'll find it well worth your while to crack the seal on the book's CD and put that toolkit to use. You'll notice that these aren't trinket programs to illustrate a point. They are thoughtfully conceived for real-world utility.
As our subitle suggests, we aim to help you master the AWT. To do that, we divide our book into two parts: exploring the AWT and extending the AWT.
Exploring the AWT
First, in Part 1 of Graphic Java, we describe the basics of using the AWT. We'll cover the range of standard classes provided by the AWT and show them in use. This includes:
Manipulating graphics, colors, and fonts
Managing events
Positioning components in the display
Manipulating images
Creating menus
To illustrate the AWT inaction, we'll draw on several custom components from Graphic Java Toolkit (GJT). Extending the AWT
Second, in Part 2 of the book, we present the Graphic Java Toolkit. In all, there are over thirty of these custom components. Among these are components such as:
Image buttons and toolbars
Separators and bargauges
Etched and three-dimensional rectangles and borders
Image and component scrollers
Rubberbands
Convenience dialogs
The GJT also includes image filters and a package of classes that developing sprite animations. You are welcome to use and incorporate into your own program development.
In describing these custom components, we highlight lessons learned and reveal tricks of the trade for those who'll be developing their own custom components. Along the way, we hope to encourage good programming practices, using Java's object-oriented features to develop elegant, maintainable, and readable code. And we try to do these things in practical terms, so that you can see and learn from examples of real programs.
Audience
This book is written for object-oriented programmers working with Java. There are numerous books explaining details of the Java language and how it works vis-a-vis Visual Basic, C, C++, et al. We leave details of how Java works to those books. If your new to Java, as most people are, you might want one of those books alongside Graphic Java.
The Graphic Java Toolkit
The CD that accompanies this book includes:
All the source code for the Graphic Java Toolkit.
Unit test applets for all GJT components, including HTML files for unit test applets.
HTML documentation for all GJT classes
Numerous image files in .gif format developed by Pixelsight
Virtually all these programs are discussed throughout the book. Feel free to borrow, adapt, or extend these for your own purposes.
The Graphic Java CD Directory Structure
Figure 11P-1 shows the directory structure on the CD.
The Graphic Java Toolkit Package Structure
Table 11P-1 shows the GJT package structure.
Table 11P-1 GJT Package Structure
Package
Contents
gjt
This package contains the source files for many of the custom components discussed in Graphic Java.
gjt.animation
This package contains a set of classes that support sprite animation.
gjt.image
This package contains a set of classes that provide support for image manipulation such as bleaching or dissolving images.
gjt.test
This package contains source code for all the component unit tests discussed in Graphic Java.
gjt.rubberband
This package contains a set of classes that support rubberbanding-stretching lines and shapes over a backdrop without affecting the backdrop.
Internet Sources of Information
There are several online sources of information on Java. You can find online guides and tutorials on Sun's home page: ...