Using null layout

Layout managers help control the size and position of all components in a container. In containers using null layout, each component defines its own bounds to determine size and location.

The visual editor provides grid markers that help you visually align components, and you can snap components to the grid. When you set to null the layout for an existing container that was previously using a layout manager, the Design view does not change in appearance. The visual editor calculates and sets the bounds for each component using the setBounds() method.

Tip: You can start with the layout manager set to null and then change to a layout (like the GridBagLayout) to get the constraint settings calculated by the visual editor for Java. The advantage of having each component control its bounds is that you can be sure that a component will always be the same size and in the same position at run time. The disadvantage of having fixed size and height is that the components will not adjust their bounds if the application is re-sized by the user. In addition, labels on components such as buttons or check boxes need to change size based on font or locale.
Related concepts
Layout managers and containers
Related tasks
Customizing UI layout in the visual editor
Using SWT layout managers
Using Swing and AWT layout managers
Specifying grid display preferences for containers

(C) Copyright IBM Corporation 1999, 2004. All Rights Reserved.