# Positioning Components in Cells

You can reposition components in the layout in the following ways:

- Anchor the component to a particular location in the cell
- Inset the component by a specific pixel amount from the edges of the cell
- Align the text in a label with the left edge, right edge, or center of the label

To anchor a component in a cell:

1. Select a component in a cell.
2. Open the attribute editor by clicking on its button in the toolbar.
3. Click on the anchor button and choose an anchor position.

To set the cell margins:

1. Select a component in a cell.
2. Open the attribute editor by clicking on its button in the toolbar.
3. In the insets box, enter the number of pixels that you want between the component and the top, bottom, left, and right edges of the cell. For example, if you want to move a label to the left and up, you could specify

   `left=15;top=8;`

To set the cell margins with the insets dialog box:

1. In the attribute editor, click the button to the right of the insets box.
2. Enter the desired number of pixels in the boxes.

To position text in a label:

1. Select a component in the grid that contains a label.
2. Open the attribute editor by clicking on its button in the toolbar.
3. Click on the alignment list and choose left, center, or right.

You can change the position of text only in a label. Other text, such as button names, checkbox names, and text in text fields, cannot be repositioned.

To resize a cell in the grid or a component in a cell, see Resizing a Component. To set the resize behavior of a component to resize with the window that contains it, see Resizing the Layout.

See also:

  Laying Out the Interface
  GUI Builder Palette
  Generating Java Source Code

  Visual Java GUI Builder API Documentation
    Visual Java GUI Builder Runtime Packages
    Class Hierarchy
    Index of All Fields and Methods