Book reviewUSENIX

 

John Zukowski
Java AWT Reference
O'Reilly & Associates, 1997. ISBN 1-56592-240-9. Pp. 1045. $39.95.

Reviewed by Bruce O'Neel
<beoneel@macconnect.com>

That groaning you hear from your bookstore is just the foundations trying to support yet another shipment of Java books. One of the better new books is John Zukowski's Java AWT Reference. He has written a huge book on that large and sometimes confusing array of classes known as the Java Abstract Window Toolkit (AWT). AWT provides the graphical user interface for Java programs, and its complexity has produced a plethora of books. This book covers both the original 1.0.2 version as well as the new improved 1.1 AWT. One of the reasons why the book is so large is that version 1.1 has a lot of changes from 1.0.2. The other reason the books is large is that AWT is just a large class library.

The book is divided into 23 chapters and 4 appendices. The first 17 chapters are the first half of the book, and they are a guide to using AWT, both 1.0.2 and 1.1. The last 6 chapters are a class reference organized alphabetically by package. Rather than include a CD-ROM, the author has an FTP site that allows you to get the sample code. I found this nice because I didn't feel that I needed yet another copy of the JDK on CD-ROM.

This should not be your first Java book. Rather than try to teach everything in one book, this just covers the AWT. You must know Java fairly well before this book will make sense.

The guide section has an overview and then covers the following Java packages: java.awt, java.awt.image, java.awt.event, java.awt.datatransfer, java.awt.peer, and java.applet. A nice feature of this section is that the chapters talk about user interface concepts such as containers and layouts and input fields that you would find easy to reference when programming. Are you doing an input text box? You could see from the table of contents that you want chapter 8 on input fields. Once there, you get a nice explanation of how to create and use TextComponents, TextFields, and TextAreas, along with some nice examples. You also would be able to see which parts of these classes you could use if you were running under 1.1 vs. 1.0.2.

I found the chapter on events and the chapter on layouts to be the two most useful chapters. The largest change from a design pattern point of view between 1.0.2 and 1.1 is in event handling. A short explanation is that in 1.0.2 when an event such as a mouse click is generated, the AWT finds a component that might be interested in this event, and then that event handler is called with that event, and the component has the option of processing it. If that event handler chooses not to process it, then AWT goes off to find another component that might be interested. In 1.1 your program objects that are interested in a particular event register for that event and are called when that event occurs. For a better explanation, see chapter 4.

The layouts chapter did a good job of explaining all five different LayoutManagers. LayoutManagers decide where to place components within containers and allow your program to run independent of the screensize and resolution. LayoutManagers also allow your windows to be resized without you having to do a lot of work to redisplay your components. The explanation of the GridBagLayout was quite clear and, if we're lucky, should cut down on the questions in <comp.lang.java.*>.

The reference section of the book has one chapter for each of the Java packages covered. This gives you a quick reference when you know what class you want but forgot what the member function is called. This is also nice for those of us who like to flip pages rather than wait for some online help system to bring up documentation on our too-small screen. It would have been nice to have a reference either to page number or chapter number where you could find the explanation and/or an example of a class in the reference section. Even so, most of the time it is very obvious from the table of contents which chapter to go to for more explanation.

In the jumble of Java books, is this a useful one? I felt it was. I enjoyed reading the guide section, and it is the book that sits next to my Powerbook when I'm programming. Is it the best AWT book? I'm not sure that is an answerable question because reading all the Java books is at best a Sisyphean task.

 

?Need help? Use our Contacts page.
First posted: 21st November 1997 efc
Last changed: 21st November 1997 efc
Issue index
;login: index
USENIX home