Graphic Java 2, Volume 1, AWT, 3/e

Graphic Java 2, Volume 1, AWT, 3/e

Back to Book

David M. Geary, Colorado Springs, Colorado


Preface

The 1.2 JDK (Java Development Kit) offers vastly improved support over its predecessors for developing graphical user interfaces and graphical applets/applications in the form of the Java Foundation Classes. The Java Foundation Classes are represented by four APIs: AWT, Swing, Accessibility and the 2D API.
The Abstract Window Toolkit (AWT) is Java's original user interface toolkit that provides a basic set of components such as labels, buttons, scrollbars etc. The AWT also includes a great deal of infrastructure for graphical components such as a delegation event model, layout management, and support for data transfer and lightweight components.
Swing is a second user interface toolkit that is built on the AWT's infrastructure. Swing offers a much more extensive set of components than the AWT; Swing's 40 components outnumber the AWT by a 4:1 ratio. Some Swing components (labels, buttons, etc.) are designed to replace their AWT counterparts, whereas other Swing components provide extra capabilities not found in the AWT (trees and tables).
The Accessibility API allows developers to implement Java applets and applications that are accessible to users with disabilities. The Accessibility API can also be used to develop alternative interfaces for nomadic users, such as a hypothetical Java navigational system that tells drivers (instead of showing them with a map display) went to turn in an audible fashion.
The 2D API encompasses a number of major enhancements to the AWT's graphics model in terms of manipulating colors, shapes and images and text.

Why The AWT and Why This Book?
The 1.2 JDK comes with the Swing set of components which includes a complete set of lightweight replacements for the AWT's heavyweight components. As a result, a common misconception is that Swing is a replacement for the AWT, but that is not the case. Swing is built on top of the AWT, and in fact, every Swing component is a bonafide AWT component. Because Swing components are in fact AWT components, it is imperative to have a good grasp of how AWT components behave and a what makes the AWT tick.
Graphic Java is meant, first and foremost, to help you master the AWT. Both fundamental and advanced concepts of the AWT are fully explored in the pages that lie ahead. Each AWT component is examined in detail, and AWT Tips are provided to illuminate some of the AWT's dark corners. No stone is left unturned.

What You'll Find Inside
After reading Graphic Java, you will have a thorough grasp of how the AWT is designed, and how to best take advantage of that design. The following is a sample of the coverage provided in the pages that lie ahead.

Peers
You will understand the peer architecture of the AWT, along with the pros and cons of the peer approach. For instance, you'll know which Component methods behave differently if invoked before a component's peer has been created, and what to do about it.

Clipboard and Data Transfer
You'll understand the data transfer model employed by the AWT, and how to utilize both local clipboards and the system clipboard. While the AWT only provides the ability to transfer strings to and from a clipboard, Graphic Java shows you how to put other data types on the clipboard, with examples of transferring both images and custom components.

Lightweight Components
In addition to being able to implement lightweight custom components, you'll also know how to drag them across a double buffered container, and even how to animate them on a playfield. You will understand how double buffering works, and why lightweight components should be displayed in a double buffered container. You will know the pitfalls of placing lightweight components in a container, and why lightweight containers must be manually fitted with a layout manager.

Layout Managers
You will have a complete grasp of layout managers, including the behemoth, GridBagLayout, and you will be able to implement custom layout managers with ease. You will understand how to force a container to layout its components, and why it is sometimes necessary to do so.

Internationalization and Serialization
You'll be able to internationalize a graphical user interface, and serialize both AWT components and their event listeners.

Scrolling
You will be able to scroll any number of components in a container by using a scrollpane. You'll also understand the limitations of the scrollpane class and why it is sometimes necessary to have a peerless scrolling framework. Of course, we'll discuss the implementation of such a scrolling framework from the Graphic Java Toolkit, which you are free to use for your own purposes.

Graphic Java Content
The delegation event model, lightweight components, clipboard and data transfer, desktop colors, mouseless operation, and printing are all thoroughly covered. You'll also find extensive coverage of scrolling, menus (including pop-up menus), image manipulation, graphics, fonts and fontmetrics, dialogs, text components, etc.

Audience
This book is written for object-oriented developers working in Java. There are numerous books explaining details of the Java language and how it works vis-a-vis Visual Basic, C, C++, etc. The details of the language are left to those books.

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:
http://java.sun.com/

There is an active net newsgroup dedicated to Java:
comp.lang.java

There is also a mailing list where Java aficionados exchange ideas, questions, and solutions. For information about the mailing list, look on the World Wide Web at:
http://java.sun.com/mail.html

From these newsgroups and web sites, you'll be able to locate countless other resources, tutorials, Frequently-Asked-Questions (FAQs), and online magazines dedicated to Java. For updates about this book and information about other books in the SunSoft Press Java Series, look on the web at:
http://www.sun.com/books/books/Geary/Geary.html

For some cool graphics, take a look at:
http://www.pixelsight.com:80/PS/pixelsite/pixelsite.html

Conventions Used in This Book


[Help]


© Prentice-Hall, Inc. A Pearson Education Company
Comments To webmaster@prenhall.com