O'Reilly logo

Special Edition Using Java 2 Standard Edition by Geoff Friesen, Chuck Cavaness, Brian Keeton

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

Mixing Heavyweight and Lightweight Components

In Chapter 14, "Building a GUI: AWT Style," you learned that it's not a good idea to mix AWT heavyweight components with lightweight Swing components. Now, you're going to see what happens when this advice is ignored. To demonstrate what can go wrong, several Swing programs will be presented. Don't be concerned about not understanding their collective source code. After you've read the next chapter, come back and study this code. You'll find that it makes more sense.

The first program—MixedDemo1—demonstrates what happens when a lightweight label is placed into the same container as a heavyweight label. The result is shown in Figure 15.3 and source code is presented in Listing 15.4.

Figure 15.3. ...

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