REVIEW - Java Swing


Java Swing


Marc Loy, Robert Eckstein, Dave Wood


O'Reilly (1998)




Peter Pilgrim


June 1999



Well done, O'Reilly for yet another winner. Java Swing is the programmer's champion of the late nineteen nineties.

Java Swing is large is a large book approximately 1220 pages long and covers the Java Foundation Classes. The JFC is the next generation user interface for Java. It consists of set of lightweight graphical user interface components to supersede the abstract windows toolkit. Professional application writers should know that the JFC is written 100% pure Java, whereas the AWT relies on heavyweight native peer components. In other words the JFC draws all of it graphics using Java primitives. The authors of JFC, with this initiative, designed the new framework to make it possible to switch dynamically between look and feels. Javasoft smartly calls this pluggable look and feel and there are three plafs that come as standard in Swing, namely Motif, Windows and Metal, which is the standard Java platform neutral look and feel.

Java Swing really attempts to cover the JFC and its philosophy within its bounds. The O'Reilly staff editors are to be congratulated for its thorough layout of properties that belong to each Java Swing component. The authors found laying out the properties in this way aiding their own understanding of how Swing worked. Advantage of this is that it saved paper (and therefore the world's rapidly diminishing rain forests), which could easily have doubled the size of the book. Their usual style and text choice is very easy on the eye. There is a more than adequate enough description of the application interface (API) and it is not simply just copied from the online manuals.

This first edition of the book appeared October 1998. Unfortunately Javasoft changed the package name of the Swing API from "*" to "java.swing.*", because they were making Swing a standard Java extension for the newest Java 2 platform. So all of the source code is out of date, but so what? You can still download the source, and there is a package renaming utility program delivered with Swing. Therefore, the book is still very up to date with just a slight modification to top of each source file. There is a thorough introduction to the JFC, the model view controller architecture, plenty of source code, examples, explanations of the former, ideas, hints and tips, description of events and swing event handling, and those very important properties. After jump-starting into Swing from chapter three onwards, the critical component classes like JComponent, JFrame, JDialog, JInternalFrame, and JWindow are all discussed. There is extensive description about the root pane containers, layout managers and border settings. You will learn about the basics JLabel, JButton, JComboBox, JList, JSplitPane, JScrollPane, and JOptionPane. The book deals very well describing the JTree and JTable. There is an example of using JTable with Java Database Connectivity for those developers who want to query databases. The table and tree components are the most discussed components in the "" newsgroups, this book will help you to understand how to fully program these vital objects.

The biggest surprise of all is amount of the book devoted to the Swing text API. This section of the book is around 265 pages long and is spread out through six chapters. Beginning with the simplistic use of the JTextArea and JTextField components, the book expands into a massive description of Swing's text document architecture. The Document model object is the basis for the internal working of the more advanced text components like JEditorPane and JTextPane. The Document model object and its descendants, which are quite complicated, but essential if you want to develop a complex application such as a language sensitive editor or word processor. The book won't show you how to do this task, in fact it would need another dedicated O'Reilly book, but it is essential reading to learn about attribute sets, document events, elements, style contexts, keymaps, editor kits, text actions, factory views, highlights and caret classes. Brilliant! It is worth the price of admission alone.

There is an entire chapter (nine) devoted to the internal frames, which allows Java applications, for the first time, to emulate the popular multiple document interface. There another chapter devoted to Swing Dialog and the extensive description of the JOptionPane. On page 288 you will find the most delightful of API tables that you will ever see about the creation of message box dialog. Menubar, menus and toolbars are also described very well. There are too many topics to write about to describe here, but what really pushes Java Swing far beyond all others including Kim Topley's "Core Java Foundation Classes" are the chapters covering Java accessibility package (for the physically challenged), the pluggable look-and-feel design and architecture, and Swing utility classes. In these tail-end chapters there is a fully working example of creating and writing a custom Swing component. There is practical help on using Swing in application, which use multiple threads.

Perhaps the only chapters that are missing in my opinion are something about drag and drop, and the extended graphics primitives that appear in the Java 2 Platform, which is also a part of the JFC. The source code is downloadable from O'Reilly examples, and does not take much to compile and to try on your own. The book will definitely help produce professional looking Swing/JFC application and will give you a thorough background of the topic. Well done, O'Reilly for yet another winner. Java Swing is the programmer's champion of the late nineteen nineties.

Book cover image courtesy of Open Library.

Your Privacy

By clicking "Accept Non-Essential Cookies" you agree ACCU can store non-essential cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

Current Setting: Non-Essential Cookies REJECTED

By clicking "Include Third Party Content" you agree ACCU can forward your IP address to third-party sites (such as YouTube) to enhance the information presented on this site, and that third-party sites may store cookies on your device.

Current Setting: Third Party Content EXCLUDED

Settings can be changed at any time from the Cookie Policy page.