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

Forcing a Container to Lay Out Its Components

It is not uncommon for situations to arise where it is necessary to force a container to lay out its components. Since the recipe for programmatically forcing a layout is not readily apparent, we'll take some time to explore the issue here.

Figure 10-5 shows an applet that contains a panel with a textfield and two buttons for adjusting the textfield's font size—the applet itself is listed in Example 10-3.

Figure 10-5. ValidateApplet. The buttons adjust the size of the textfield's font. After the font size is adjusted, the applet needs to be laid out in order for the textfield and its container to resize to accommodate the new font size.
Example 10-3. ValidateApplet Class Listing
 import java.applet.Applet; ...

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