Some Java beans allow relationships between themselves. For example, the class java.awt.Container allows instances of java.awt.Component to be added to it as part of its components relationship. An example of java.awt.Container is a panel or a frame. An example of java.awt.Component is a button or a text box. In the Visual Editor for Java, containment relationships are shown in the Java Beans view and in the Design view.
A layout manager is an object that controls the size and position of components within a container. You can choose to set the layout manager on a container to null, thereby allowing each component to size and position itself. However, the position of the GUI components will not correspond to the changes you make when you resize the window. Rather than having a fixed size and position for each component, the container will delegate the sizing and positioning of its components by using a layout manager.
Each layout manager has its own rules for distributing the components, but most place each component so that they are at least as big as their preferred size. The preferred size of components with user visible strings, such as button or label, is calculated dynamically. So, as the string length changes due to different locales or fonts, the layout manager will reposition each component. As the window is resized by the user at runtime, a layout manager will also reposition each component to optimize the new overall size. This makes layout managers invaluable for building GUIs that will be deployed in an environment where label strings, fonts, or window size may vary.
The Visual Editor allows you to set the layout manager of a container to:
These topics are covered separately in the documentation.
If you use a layout manager not supplied in the Visual Editor, the Design view will still construct the container correctly and render the components. However, you won't be able to update constraints using the Properties view or Design view.
Related concepts
Flow layout manager
Null layout manager
Border layout manager