O'Reilly logo

Java Swing by Dave Wood, Marc Loy, Robert Eckstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 28. Swing Under the Hood

Roughly halfway through writing this book, we sent mail to several Java newsgroups asking what sort of topics you, the Swing developers, would really like to see explained in more detail. We received a tidal wave of responses, many about a variety of arcane Swing topics. Of those that were not covered elsewhere in the book, most of the replies revolved around the same five areas:

  • Creating your own Swing component

  • Dealing with the Swing focus manager, and writing your own focus manager

  • Mixing lightweight and heavyweight (Swing and AWT) components in Swing

  • Multithreading issues in Swing

  • The Swing RepaintManager

So, in response to your requests, we offer this loose collection of tips, tricks, and things that made us cry “Eureka!” at about two in the morning. Since many of these topics had little or no documentation when Swing was created, the three of us had to dig through the Swing source code much more than normal to answer these questions. Hence, we call this chapter Swing Under the Hood.

Creating Your Own Component

So you’ve been bitten by the bug. There isn’t a component anywhere in the Swing library that fits your needs, and you’ve decided that it’s time to write your own. Unfortunately, you’re dreading the prospect of creating one, because either you’ve heard somewhere that it is a complex task, or your jaw is still bouncing on the floor after browsing through some of the Swing component source code.

This section helps to dispel those fears. Creating ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required