Showing the grid for GridBag layout

When using the GridBag layout manager, you can show or hide the grid in Design view.

Because GridBag layout can be difficult to visualize, you can set the Design view to display the grid while you are laying out your interface. As you click and drag components to different areas, you can easily design your application since you know exactly where each component is on the grid. You can then hide the grid when your layout is complete.

The visual editor uses red, dotted lines to indicate the current borders of the grid. Values for the column numbers across the top of the grid (the x value) and row numbers down the left side of the grid (the y value) are displayed as numbers in blue circles. The rows and columns begin their numbering with 0. So, the upper left corner cell is labeled originally as 0,0. As you add components, rows and columns are numbered sequentially based on the previously used number.


GridBag layout grid
Note: If a grid number is skipped, it indicates that there are no components that are using that specific grid x or grid y setting. This can occur if you add and remove lots of components or move components around. The GridBagLayout allows x and y values to be skipped, and simply lays out the x,y values in order, relative to other x,y values set for other components, even if values are skipped.

To show a grid for the GridBag layout manager:

  1. In the Design view or Java Beans view, select the component that is using GridBag layout as its layout manager.
  2. Right-click and select Show grid from the pop-up menu.
Note: To hide a grid that is already showing, follow the previous steps, but select Hide grid from the pop-up menu.

Parent topic: Using GridBag layout

Related tasks
Adding or moving components within GridBag layout
Adjusting fill, anchor, and inset constraints in GridBag layout
Spanning components across GridBag rows and columns

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