by Joshua Marinacci and Chris Adamson
Reviewed by Robert Eckstein
Because I've authored a book about Java Foundation Classes/Swing (JFC/Swing), people often think that I must know everything about JFC/Swing. Of course, I don't. Swing is an enormous API, and the encyclopedic book that I coauthored in 1998 leaves no stone unturned in the world of components that start with J.
The good news is that, with such a large book, I can often deny having intimate knowledge of a particular API and blindly say something like, "My coauthor wrote about that component!" -- especially if I've forgotten how to use it. The bad news is that I often find myself wishing for a deeper level of experience with all of those components, only a third of which I wrote about.
No sweat. With a little help from Swing Hacks: Tips and Tools for Building Killer GUIs, I can once again fool the world into thinking that I know everything there is to know about Swing. The book starts off with a bang, helping you to create snazzy-looking components by overriding the
About the Book
If you were at the 2005 JavaOne Conference, you may have dropped by two technical sessions on the topic: TS-3605: Extreme GUI Makeover and TS-3214: Advanced Java 2D API Topics for the Java Desktop. Both gave sound advice on making your Swing components look much better. This tip uses the same technique, overriding
Chapter 6, "Transparent and Animated Windows," is one of my favorites because it continues this theme and helps my Swing components look a little more Mac-like. Creating transparent windows, creating frame-anchored sheets for dialogs, animating the sheet dialog, and sliding notes out from the taskbar are some of the hacks in that chapter. All it takes is a little knowledge of the Swing heavyweight component glass pane, and you're up and running.
Buried in Hack 54 is an invaluable gem: Want to antialias all the text on your Swing application without touching any code? No problem, just add the following definition to the command line when you invoke your application:
java -Dswing.aatext=true MyStartClass
Chapter 10, "Audio," is also a good chapter to look at, because many Swing programmers tend to overlook sound as an important part of their application. Maybe you want the swishing sound of a folder closing or of a clanging trash can when you throw away something in your Swing application. Hacks 70 through 73 discuss playing sounds with applets, JavaSound, the Java Media Framework, and Quicktime for Java technologies. Hack 74 shows you how to add MP3 support to the Java Media Framework API as well. (Is that a Swing hack? Not really. But it's pretty simple to execute, and I'm glad it's there.)
Chapter 12, "Miscellany," presents us with some obvious tricks and some very important tips. For example, most programmers know that whenever they write event-handling code, such as an
One note: I need to disclose that I used to work for O'Reilly Media, Inc. as an editor, back when it was called O'Reilly and Associates, Inc. That being said, I don't get any royalties from this book, nor am I rewarded for reviewing it in any way, shape, or form. All I get is a free copy of the book, which I can peruse whenever I need to dazzle people a little on my Swing programming.
All in all, Swing Hacks is a solid book that covers a great deal more than just the basic best practices that you would expect inside the standard encyclopedic Swing tome. It's a good book to have around when you need advice on working with components, you want to speed thing up a little, or you just want to make things a little jazzier.
Table of Contents
Curious about this book? Take a look at the table of contents at the publisher's web site.
You can order Swing Hacks: Tips and Tools for Building Killer GUIs from the following sites:
By the Way...
If you are a Java technology publisher and would like me to review your J2SE, J2ME, or J2EE book, don't hesitate: Send me an email right now. No, I mean it. Stop what you're doing and write me. Have you contacted me yet? Okay, good. And now for my standard disclaimer: I won't review every book I receive, but we all know that there are some gems out there that really deserve the limelight. So let me know what they are.
Oracle is reviewing the Sun product roadmap and will provide guidance to customers in accordance with Oracle's standard product communication policies. Any resulting features and timing of release of such features as determined by Oracle's review of roadmaps, are at the sole discretion of Oracle. All product roadmap information, whether communicated by Sun Microsystems or by Oracle, does not represent a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. It is intended for information purposes only, and may not be incorporated into any contract.