Mixing Layout Managers

At this point, you might be wondering how Java's layout managers will work with the kind of graphical user interface you want to design. Choosing a layout manager is an experience akin to Goldilocks checking out the home of the three bears and finding it lacking: "This one is too square! This one is too disorganized! This one is too strange!"

To find the layout that is just right, you often have to combine more than one manager on the same interface.

This is done by adding containers to a main container such as a frame or an applet window, and giving each of these smaller containers their own layout managers.

The container to use for these smaller containers is the panel, which is created from the JPanel class. Panels are ...

Get Sams Teach Yourself Java 2 in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.