Swing painting pipeline – the conclusion

August 7th, 2007

Over the past two weeks i have presented a few solutions to paint validation overlays in Swing. The sheer variety of the solution spectrum serves to highlight the extensibility of the Swing painting pipeline.

Swing painting pipeline 1

Swing painting pipeline 2

As can be seen from even such a simple example as validation overlays, there are many ways to achieve the desired functionality in Swing, each one having its advantages and disadvantages. This variety is, perhaps, Swing’s biggest blessing and biggest curse. On one hand, if you know how Swing works, you can achieve almost everything. On the other hand, if you’re a novice developer, it’s just too much to handle.

In addition, you need to be fully aware of the limitations of each technique to choose the one that best suites your needs. There is no single silver bullet that works best for all requirements, and in most cases the best solution would be a combination of two or even more working together. Hopefully this series has helped you put a few more tools in your developer arsenal. So the next time you need to provide some custom painting functionality, look at the Swing painting pipeline, weigh all the options and go with the one that would work best for your specific requirements.

To sum up, here are the links to all the entries:

  1. Repaint manager
  2. Overriding paint() manually
  3. Using AOP to override paint()
  4. Custom border
  5. Layered pane
  6. Glass pane
  7. JXLayer
  8. Extending look and feel
  9. Multiplex look and feel