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.
- To specify universal settings for how the null grid markers display,
see Specifying grid display preferences for
containers. To customize the spacing of the grid markers for the selected
container, open the Customize Layout
window and specify the
width, height, and margin sizes for the grid.
- To force items to snap to the grid markers as you drop them or
move them on the null layout, right-click the container and select Snap
to Grid. With Snap to Grid selected, you
can easily align components visually.

To override the snapping
to grid for a component, hold down the Alt key while you drop or move the
component. This allows you to place a component between grid markers.
- To resize a component in null layout, click and drag the component's
handles:

You can also set the size of
a component as you add it from the palette. Simply hold down the left mouse
button when you drop the component in the Design view, and drag the mouse
pointer. In any other layout manager, you cannot size a component as you add
it.

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.