O'Reilly logo

Graphic Java™ 1.2, Volume I: AWT, Third Edition by David M. Geary

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

Lightweights and Preferred Sizes

Preferred sizes for heavyweight components are is calculated by the component's peer, whereas the preferred size for heavyweight containers are is calculated by the container's layout manager.

On the other hand, by default, a one-pixel square is the value for preferred sizes for lightweight components, by default, is a one-pixel square. As a result, lightweight components should override getPreferredSize() to ensure that they are sized according to their preference. Of course, overriding preferredSize() does not guarantee that the lightweight will be sized according to the dimension returned from preferredSize() because the shape of both heavyweight and lightweight components depends upon the layout manager that ...

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