Components, Containers, and Layout Managers
Much that is involved in understanding GUI programming and toolkits is learning a set of names and definitions for things with which you are already familiar.
Anonymous teacher of a course in internet programming using Java
Here are informal, working, definitions of the terms in the title.
- Component
- A functional element of an applet window. For example,
- Buttons
- Text Areas
- Scroll Bars
- Containers such as Panels.
- Container
- A Component that contain other Components.
- Layout Manager
- Software that controls the organization and size of Components in the applet window or a Container.
In the previous section we saw some simple applet layouts. Here is a detailed presentation of the "kiosk" layout.
Layout Managers
- Working with Layout Managers requires two levels of understanding.
-
- general- What the final layout is expected to look like.
- specific- What is the "layout policy" (w.r.t. size etc.in laying out the components).
The Tutorial has a good discussion of the various layout managers. Here is a brief introduction to two of them.
- Flow Layout
-
- general- Lay out. components in rows
- specific- This is the default Layout of a Container. Place Components in rows, left to right then top to bottom within the Container in the order they are added. Center rows and space evenly.
- Border Layout
-
- general- Place up to five Components in a Container in positions "North", "South" ,"East", "West", and "Center".
- specific- Place the North and South Components along the top and bottom of the Container. Next, place
the East and West Components along the right and left sides( The bottom of the North and top of South are the new top and bottom).
Finally, place the Center Component in the space that is left.
The AWT provides other useful Layout Managers.
- CardLayout
- Displays one Component at a time from a "deck" of components
- GridLayout
- Lays out components in a grid of rectangles of the same size
- GridBagLayout
- Lays out components in a grid of rectangles of different sizes. Uses complex
rules with parameters that are user defined
URL: https://www.umsl.edu/~siegelj/newcourse/part4/cclm.htm
Copyright: Jerrold Siegel for The University of Missouri -St. Louis
Last modified on 09/24/2000 14:15:56