Chapter 4. Laying Out Components within a Container
http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html
This chapter tells you how to use layout managers, which are objects that control the size and position of components in a container. It also tells you how to use absolute positioning (no layout manager) and presents an example of how to write a custom layout manager. How-to information for each of the commonly used layout managers is in Chapter 8, Layout Manager Reference (page 457).
The chapter contains the following sections:
A Visual Guide to Layout Managers shows examples of the standard layout managers and points to each one's how-to section. Using Layout Managers includes how to set the layout manager, add components to a container, provide size and alignment hints, put space between components, and set the orientation of the container's layout so that it's appropriate for the locale in which the program is running. The section also has some tips for choosing the right layout manager. How Layout Management Works goes through a typical layout sequence and then describes what happens when a component's size changes. Creating a Custom Layout Manager tells you how to write your own layout manager. Doing without a Layout Manager (Absolute Positioning) discusses setting the size and position of components directly.
Solving Common Layout Problems (page 738) in the Appendix tells you how to fix common layout glitches.
A Visual Guide to Layout Managers BorderLayout BoxLayout CardLayout FlowLayout GridBagLayout GridLayout SpringLayout
Using Layout Managers Setting the Layout Manager Adding Components to a Container Providing Size and Alignment Hints Putting Space between Components Setting the Container's Orientation Choosing a Layout Manager
How Layout Management Works Creating a Custom Layout Manager Doing without a Layout Manager (Absolute Positioning) Summary Questions and Exercises Example Programs
|