REVIEW - Programming with JFC


Title:

Programming with JFC

Author:

Scott R. Weiner, Stephen Asbury

ISBN:

Publisher:

Wiley (1998)

Pages:

564pp

Reviewer:

Peter Pilgrim

Reviewed:

December 1998

Rating:

★★☆☆☆


Intro

It has been a long time. I have just finished taking my exams in higher level German, and I am about to go away on holiday. During the last three months I have been developing Java software to connect to a relational database. It is thereabouts that I was introduced to Swing.

One of the criticisms of Java programming language and its environments was the fact it had only one standard user interface with only simple type components. The AWT (abstract window interface) left much to be desired: it is not rich in features that many professional application programmers need. For example if you compare the variety of components in AWT with those available in the Microsoft Foundation Classes. SunSoft decided more than a year ago how to tackle this problem. Their developers came up with the idea of a powerful plug and play look and feel user interface based on lightweight components. The first demonstration of the concept took place at the JavaONE conference against a backdrop of a Duke Ellington jazz music. The Swing Java component objects draw their componentgraphically using Java graphics, without relying on the heavy-duty system-dependent API. In other words the new components are a 100% Pure Java meaning maximum portability (as long as your site supports the requested pluggable look and feel). The Sun developers also took advantage of a fundamental design pattern in object oriented design. They separated the application code from the pluggable user interface code by using the MVC (Model View Controller) pattern. The Swing components are all Java Beans compatible, so any Java based user interface builder tools should be able to load any swing components.

It is very easy to get started with Swing. In fact by simply prefixing most of the AWT objects with the `J' letter you could convert an application in a day or so. I know this because I upgraded my Java SQL editor code using this method. The trouble is that most experienced Java developers do not have enough documentation on using Swing beyond the basic uses. Perhaps this is why the following books were rushed released. The only reliable introduction beforehand was a 12-page appendix in the O'Reilly book Java Examples in a Nutshell' .

My last great GUI adventures came from battling with OSF Motif/X Window Intrinsics toolkit. The best book I ever found for programming was O'Reilly's Motif Programming Guide: X Window Series, Volume 6 (also see Motif Programming Manual Volume 6A ) . It was around 1000 pages long at around£25, but every single chapter was useful.

Up To Speed with Swing

Up To Speed with Swing is published by a house, which is very new to me. The book is just under 500 pages long. The introduction starts very well with a review of Java programming of course the AWT, and the new event handling methods in the JDK1.1 release. It describes what Swing is, and presents the MVC concepts quite well. Above all it describes the mother of all components
JComponent
.

Happily the book deviates from many mediocre GUI programming books by looking at Panels and Panes first, followed by the layout managers and containers, instead of jumping into the usual push buttons, check boxes, and radio buttons. Each new component is introduced with a short description of its use. A short example always follows. There is a good variety of comprehensible examples, then come the advance examples. Perhaps a little more text could have been written to describe the more significant points in the examples. I am thinking of the developers who have not written a lot Java/AWT code. However there is enough reference material describing the important constructors and most significant methods related to each Swing component.

The newer components like the

Japplet, JProgressBar, JTree
and
JTable
are described, but fortunately with a bit more detail. I am a bit surprised that there was no example connecting a
JTable
to a result of database query. There is enough good information to design a full application with menubars, toolbars and dialogs. Finally the book concludes with advance topics describing how to create your own pluggable look and feel. There is also a look behind the scenes at the User Interface manager and a section on how to optimise your JFC programs. The last appendix talks about various builder tools like JBuilder.

The book is expensive for its type, there is no CD-ROM, however the code is downloadable from Manning's web site. Manning is a new publisher on the block and the book is not bad at all. It is quite useful and you will learn how to swing by looking at the examples and from your own experimentation. The authors are making themselves available for comments on-line as well.

Programming With JFC

Here is a book for the concise developer. It uses a chunky, but thoughtful typesetting to add to its flavour. The font size of the normal text is small compared to that used in the source code listings. However relevant points in the example source code are emphasised in bold. This is nice way of emphasising!

The book is just over 550 pages long and has a shorter introductory description of what Java and AWT are. The introduction of the lightweight components, JFC, event handling, etc. is very good. Here an overlooked feature of the Swing API is specially described: the slow motion graphics drawing for debugging Swing components.

The next chapter takes up the theme of the layout managers, boxes and borders and then jumps to the usual theme of buttons, radio buttons and check boxes. What is good at this point is the description of action events and mouse input, and how to bind your application to the Swing API.

Each chapter ends with a style guideline, which advises when to apply that type of component. It is a variation on the end of chapter summary in similar texts. The description of the API methods and constructors are nice, because much of it is presented in easy-to-browse tables, complete with a method signature and a short description. I personally found the information on the new message box and option box dialogs engaging.

There is a fair amount of information about the new Swing components like the

JSlider, JScrollPane, JTable, JTree
and
JTextComponents
. Overall the design of Swing components are pleasantly revealed as you read on. I found the JTable chapter description to be rather good. There is a handy example of a
JTable
component displaying familiar rows from a database using the JDBC interface. Of course the
JMenuBar
and
JMenu
components are given the full example treatment. There is a useful insight in the new Timer and Progress Bar components for more advanced developers. The book scores a big win by a least describing the undercover items, like the mysterious root, glass, and layered panes, which are related to almost all Swing components.

There is a step by step guide in the final chapters available, when you will feel you need create your JFC components. You are warned about the many of idiosyncrasies. The book at least presents a position on the Undoable framework, how to add animated graphics icons, custom list data models, and of course the pluggable look-and-feel architecture. Two full-length application examples are introduced. The first is a tar and zip file viewer. The second parameter is HTML web page search program.

My Vote

Both books have an excellent standard of Java coding. The examples are clear and comprehensible. There is lot more information to gained from reading these books than if you just tried to read source code for the Swing demo application. If you are looking for value for money then go for the Wiley book (also because of the CD ROM includes the latest Swing 1.0.1, and Windows 95 and Solaris version of the latest JDK 1.1, Alchemy Gif Builder, all the book's source code examples, and shareware software.) It also edges in front of Up To Swing because there are two full application examples to study: the Jar and Zip file viewer, and the HTML document search program.

Up To Swing includes a description of the
JFileChooser
and
JColorChooser
components, but you are warned that information is already out of date, because SunSoft is still tinkering with the API. Programming with JFC omits describing these components until the next edition of the book. Perhaps these extra chapters may be published on the website.

Swing will work on any Java Development Version greater than 1.1.3. You can get by only with the Swing on-line documentation, but you would be missing the point by a fair mile. With these two books there is no excuse for your user interfaces being drab and dreary ever again.

I still feel that Swing and JFC have not been given a quite decent description. Only

Programming with JFC had a real practical example application to inspire a design project. Maybe O'Reilly are about to introduce the mother of all Swing JFC books to reach the same acclaim as their excellent X Window Series did several years ago.

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.