Swing, Second Edition

Matthew Robinson and Pavel Vorobiev
Foreword by James Gosling, "Father" of Java

2003 | 912 pages | B&W
ISBN: 193011088X

Out of Print $49.95 Softbound print
$39.99 eBook edition (PDF only)



This book builds on the successful approach of the first edition of Swing, once again taking the power and flexibility of Java's Swing library to its limits. Using a fast-paced style, it starts by introducing each of the Swing components and continues with production-quality code examples in which Swing features are customized, combined, and vigorously exercised to demonstrate real-world usage.

With over 400 pages of revised text, additional examples, and new material to bring the book up to date with J2SE 1.4, Swing Second Edition includes complete coverage of the new JSpinner and JFormattedTextField components, the new Focus and Keyboard architectures, and many other new and enhanced Swing features. Three new chapters have also been added to cover the construction of HTML and XML editor applications, and how to work with the new Drag & Drop architecture.

What's Inside:


Matt Robinson, cofounder of Santa Clara-based Recruitforce.com, has four years' experience as a Swing engineer working on enterprise software. He has written numerous contributions to Java books, magazines and academic publications. Pavel Vorobiev, also a Recruitforce cofounder, has 16 years of software development experience at both small and large companies such as Iona, i2 Technologies and Merrill Lynch. He is the co-author of four earlier Java books.

Sample Chapters

Chapters 11 and 20 of Swing Second Edition are available here in Portable Document Format (PDF); you need Adobe's free Acrobat Reader software to view them. You may download Acrobat Reader here.

Download Chapter 11.

Download Chapter 20.

The complete first edition of Swing is available as MS Word 97 documents. Note that the material freely available here represents Swing in its final stages of development before it was sent to Manning's copyeditors and typesetters. The actual book available for purchase features significant improvements in formatting and presentation, including annotated code callouts (see PDF chapters above).

Download Complete Swing Book (MS Word 97).


It's been amazing to see the applications that have been built using Swing. It is an extraordinarily sophisticated user interface toolkit that gives great power to developers. This power leads to the biggest problem with Swing: the wide variety of facilities can be intimidating. One's first contact with the Swing APIs can be a little like sticking your head into the cockpit of a 747: a dizzying array of levers and dials that can be confusing. But there is a logic to it all. Once you know the territory, it's easy to get around and the available facilities will make your job much easier.

The authors of this book have done a great job mapping out the territory and explaining the standard patterns that make Swing great. I love the way they have gone beyond just laying out the APIs to covering issues about what makes a good user interface, and what makes an application easy to understand and use. They also go beyond the usual snippets of code to develop complete applications. This is a great way to inter-relate all of the parts of the Swing API.

James Gosling
Vice President and Fellow
Sun Microsystems


"The book is not for those readers who are seeking entry-level training in Swing; it is a book for professional programmers who require information about how to get their Swing projects onto the right track, fast. ... This book is a complete, but final training. ...a must-read for every Swing programmer."
-- Computing Reviews, Nov. 2003

"a definitive self-teaching aid and resource for intermediate to advanced level programmers."
-- The BookWatch, May 2003
-- The MidWest Book Review

Swing Second Edition has been declared "the Bible of Swing" earning 10 out of 10 horseshoes at JavaRanch.com:

"The coding samples you will find in this book are extremely detailed and well commented. If you want to learn how to be a competent Swing developer then you should get this book."

Read the whole review at JavaRanch.com

What the experts said about the first edition

"Looking for a book on Swing with in-depth coverage of the how's and whys? Then Swing by Matthew Robinson and Pavel Vorobiev is it... an excellent introduction to the concepts of Swing. Developers looking for the 'Hello World'application won't find it here. In its place are exhaustive coding samples with detailed explanations. The authors take great care to discuss the importance of threads in Swing, focusing on multi-threading and how to build thread-safe methods. Throughout the book the authors also make it a point to include UI delegation examples and when to use the default implementations and when to override them. Overall this is an excellent book, and I would recommend it for the intermediate to advanced Swing developer.

An EXCEPTIONAL 10 out of 10 horseshoes."

"...The authors do a credible job of covering the Swing classes (and then some)...The examples are more varied than most equivalent books and the manner in which the code is commented on (annotated sidebars with more complete comments following) is superior to many other methods I've seen..."
-Ed's Internet Book Reviews, May 2000

"!!! Very Good"
-Today's Books/Public News Service

"How many times have you opened a book in search of a solution and found not only an answer, but also an elegant enhancement to your application? How many times have you ignored an O'Reilly book on the same subject lying on your table? The answer is Manning's new book Swing authored by Mathew Robinson and Pavel Vorobiev. And that is my final answer."
-Reviewed by Jayakrishnan on slashdot.orgApril 11, 2000

"UI development is a very time consuming business. Even with such a powerful next generation API at your fingertips it can be still overwhelming. Swing is a wonderful book that lightens the burden. It presents a complex subject in smaller manageable portions for the programmer who has learned the basics and wants to go much further. This excellent book is impossible to take in the first time, because of the scope and breadth of its subject matter. I think you will find that it hits and hits its target audience and goals again and again. It does not fail to satisfy. A massive quality and quantity win-win for Manning. Trust me. You will love it.

"Swing continues where Manning's own Up To Speed with Swing and O'Reilly's Java Swing stops. Throughout the book there are helpful bugs to avoid and developer notes...No other book on the same topics reaches the quality and quantity of this book. Presentation, content, overall developer satisfaction make this book a best of breed winner."
--Peter Pilgrim, Reviewer
Association of C/C++ Users

"I recommend this book to any serious Swing developer. What impressed me most was the focus on developing comprehensive examples. The useful designs both demonstrate the technologies and leave the reader with a practical starting point for professional development. All in all, this is a great value for any Swing developer."

"...one of the best books available for learning the more advanced Swing features."
-Marty Hall, Senior Computer Scientist, The Johns Hopkins University Applied Physics Lab
-Author of the book Core Servlets and JavaServer Pages.

Source Code

All source code examples for both editions of the book are freely available.

Download Swing Second Edition Samples (5.84 MB).

Download Swing First Edition Samples (6.67 MB).

The Story of Swing

The Story of "Swing" (Notice the Quotes)

Manning just released "Swing Second Edition" by Matt Robinson and Pavel Vorobiev with a Foreword by James Gosling. The following is an account of the history of this book as recounted by Manning's Publisher, Marjan Bace.

A parent who does not admit to having favorites is self-deceiving: children are individuals and we like them more or--heaven forgive--less, depending on how we respond to their personality. Yes, they do come from identical genetic and environmental backgrounds but to conclude that they are therefore "equal" is mistaken--they are only equal statistically. And so it is with a publisher and his "children," the books he has helped bring to life. I have to admit I cannot always manage to remain unbiased although I generally do try to keep my preferences to myself. Not so in this case.

"Swing" has qualities that appeal to me--it's a Manning book I'm proud of. Apparently, it also appeals to many readers: it has sold well over the years in spite of lots of available competitors. The first edition's entire content is available online, and has been since before it was first published in January 2000. The online content is mirrored in a couple of locations in Europe. It routinely comes up on the first page of Google when you search for "swing." We receive requests for permission to reuse the code from the book in commercial apps all the time. The second edition sales have started off nicely too, and the endorsement in its Foreword by James Gosling must not be hurting.

BTW, we got into this free-manuscript situation by accident: as we started working on this book the "Cathedral and the Bazaar" appeared and we fell under its spell. We decided that writing a book was not all that different from writing software and opened up the manuscript to the Swing community. But books are different from software and the experiment basically failed. I'll describe that experience one day. (Oh, and here's an example of why it's a Good Thing to write for publication: looking for the original CaB URL I found "A Second Look at the Cathedral and the Bazaar." I can't wait to read it.)

Anyway, what I really enjoy about "Swing" is that we keep hearing from people how much they appreciate it. They tell us how unique they think it is. The examples are industrial strength, not toy examples, and this is rare in computer books.

The editor who worked on the book during its long incubation, Ben Kovitz, came up with a way to counter the visual boredom of long code listings: he took all comments out of the code, which made it shorter, and added graphically attractive annotations next to it. The annotations guided the eye to the important code segments. Our market tests indicated readers would like them, and they did. We have continued using Ben's annotations in many later books.

"Swing" was originally a followup to another book, our "Up To Speed with Swing." "Up To Speed" was the first book to be published in what was a hot Swing market. It was a basic tutorial and we felt people wanted more depth. The best way--and really the only practical way--to give them depth was to show them lots of examples of how to do things.

So, we signed Matt and Pavel to write "Swing by Example." As they wrote, we kept getting asked by manuscript reviewers to include basic information about the library. The manuscript didn't include this information so they had to look for it somewhere else. They wanted it all in one place. Although the book was in danger of getting obese, I agreed to expand its focus and we ultimately changed the title simply to "Swing." A faint trace of that history remains in the "sbe" of the book's URL: www.manning.com/robinson2.

In the past Swing had problems with speed. It was, and is, a powerful library that requires a large effort to master. The speed problem has gone away due to continuous improvements in the library and increased processor speeds. Its complexity remains, though, and a book like "Swing Second Edition" is a good way to master it. Well, let me restate that: this Second Edition is the best way to master Swing. And that is a biased opinion.

Marjan Bace, Publisher
Manning Publications