The Book

Filthy Rich Clients

by Chet Haase and Romain Guy

Create stunning visual and animated effects with Swing and Java 2D. Learn graphics and animation fundamentals as well as advanced rendering techniques.

Introduction to Filthy Rich Clients

Filthy rich clients are applications that are so graphically rich that they ooze cool. They suck the user in from the outset and hang onto them with a death grip of excitement. They make the user tell their friends about the applications. In short, they make the user actually enjoy their application experience. When was the last time you enjoyed using a software application? Maybe you need more Filthy Rich Clients in your life.

In Filthy Rich Clients, we explain how to create filthy rich effects in your applications, from the fundamental graphics, GUI, and animation technology up through sample code and algorithms for the effects themselves.

Some of the topics covered in-depth include:

  • Graphics and GUI fundamentals: Dig deep into the internals of how Swing and Java 2D work together to display GUI applications on the screen. Learn how to use these libraries correctly and effectively.
  • Performance: Follow in-depth discussions and tips throughout the book that will help you learn how to write high-performing GUI applications.
  • Images: Understand how images are created and used to make better Java applications.
  • Advanced Graphics: Find out about elements of Swing and Java 2D that may not be in common use but that filthy rich clients benefit from greatly.
  • Animation: Discover general concepts of animation, as well as how to use the facilities provided in the Java platform. Learn about new utilities that vastly simplify animations in Java.
  • Effects: Learn how to create and use static and animated effects that are the mainstay of filthy rich clients.
  • Every chapter is filled with code examples which come directly from demos and libraries posted on this web site.

Read the book. Run the demos. Understand the code. Write some filthy rich clients of your own. Your users will thank you!


Filthy Rich Clients covers many graphics-related topics. The following outline describes the structure of the book and gives you a clear description of its content:

  • Part I, Graphics and GUI Fundametals
    1. Desktop Java Graphics APIs: Swing, Java 2D, and AWT
    2. Swing Rendering Fundamentals
    3. Graphics Fundamentals
    4. Images
    5. Performance
  • Part II, Advanced Graphics Rendering
    1. Composites
    2. Gradients
    3. Image Processing
    4. Glass Pane
    5. Layered Panes
    6. Repaint Manager
  • Part III, Animation
    1. Animation Fundamentals
    2. Smooth Moves
    3. Timing Framework: Fundamentals
    4. Timing Framework: Advanced
  • Part IV, Effects
    1. Static Effects
    2. Dynamic Effects
    3. Animated Transitions
    4. Birth of a Filthy Rich Client

Download the Demos

The source code for all the examples and demos from the book is available on GitHub at under the BSD license.

Users of NetBeans 6 and up can download and install the Filthy Rich Clients NetBeans plugin. When installed in the IDE, you can use the File > New Project... menu to open any of the demos from the book.

Dependencies: The examples might require the following two libraries to work properly. When required, the binaries are included in the source tree of each example but you might want to download these libraries separately.


You want to know what others think about the book? Check out the following reviews.


You want to check out the book's contents? Take a look at the following excerpts.


Despite our efforts the book is not perfect and your edition might contain a few mistakes or it might lack a piece of information. This section contains corrections for some chapters.

Chapter 2

Figure 8 is wrong. The explicit call to process(V...) should be a call to publish(V...). You can download the correct figure.

Chapter 4

On page 111, note that the getFasterScaledInstance() was only intended for downscaling images. If you use the method as written for up-scaling, you may hit an infinite loop problem. The workaround is simple (don't got into the if (progressiveBilinear) block if the targetWidth or targetHeight are greater than the current width/height values. Or simply don't use this method for up-scaling.

Chapter 6

One page 155, resultG and resultB should be calculated with srcG and srcB, respectively (they incorrectly use srcR in the example code.)

On page 173, the createContext() should return an AddContext instead of a BlendingContext.

On page 174, the last paragraph should read To implement the AddContext [...].

On page 176, the last paragraph should refer to srcPixelsArray and dstPixelsArray instead of srcPixels and dstPixels.

Chapter 18

Effect memory leak

In order to address a memory leak that comes from adding (but never removing) PropertySetters to the Animator used for ScreenTransition, there is a new method in Effect:

public void cleanup(Animator animator);

This method is a parallel to the existing init(Animator) method, only this one is called after the transition is complete, and gives the Effect a chance to clean up after itself (such as removing targets from the Animator). For example, the supplied Move effect adds a PropertySetter to ScreenTransition's Animator object in its init method:

PropertySetter ps;
public void init(Animator animator, Effect parentEffect) {
  Effect targetEffect = (parentEffect == null) ? this : parentEffect;
  ps = new PropertySetter(targetEffect, "location",
      new Point(getStart().getX(), getStart().getY()),
      new Point(getEnd().getX(), getEnd().getY()));
  super.init(animator, null);

The cleanup method, then, is responsible for removing ps after the transition is complete:

public void cleanup(Animator animator) {

You may not need to use this method, or know about this detail at all, in your animated transition code. But if you define any custom effect (such as the MoveIn effect in the SearchTransition demo) then you may need to override cleanup() to avoid memory leaks.

Cleaning Out EffectsManager

EffectsManager makes it possible to set custom effects for an application, but not (until now) to remove thoes effects. You could set an effect for a component to null, but you could not actually remove the component from the cached list of components with associated effects.

To fix this, EffectsManager now has three new methods:

public static void removeEffect(JComponent component,
                                TransitionType transitionType);
public static void clearEffects(TransitionType transitionType);
public static void clearAllEffects();

removeEffect() removes a single effect associated with a component and transitionType, clearEffects(transitionType) clears all effects for a given transition type, and clearAllEffects() clears all effects regardless of the transition type.

Chet Haase

Chet is a client architect in the Java SE group at Sun Microsystems. He works with all of the desktop Java technologies, including Swing and Java 2D, and focusing on how to improve the platform. His passion in software is graphics, and he has spent most of his career (apart from a short stint just after college, when he realized just how dull "network analysis" is) working with graphics technologies of all kinds, from 2D to 3D and from the application down to the driver level. Chet received his B.A. in mathematics from Carleton College and his M.S. in computer and information sciences from the University of Oregon.

Romain Guy

Romain wrote this book during his final year at school and while obtaining his M.S. in computer science. His passion in software is graphics and graphical user interface development, and he has spent many years working with Java and Swing. Romain cannot stand still and has worked as a freelance journalist for programming magazines for years, as a book translator for O'Reilly, as a Java teacher in a French university, as a videogame developer, as a freelance developer, as a software engineer on the Swing Team at Sun Microsystems, and as a software engineer at Google. His new passion is digital photography.

Contact Us!

We are pleased to receive your comments and feedback about the book and its demos. You can contact us at the following email addresses for any matter concerning the books and its derived material:

  • Romain Guy <romain.guy -at->
  • Chet Haase <chet.haase -at->