The Design Grid

  Basic operations
  Column width and row height
  Column weight and row weight
  Column weight usage and row weight usage
  Size modes

A divides a rectangular area into a number of rows and columns. Both row and column numbering start with 0.


Basic operations     Top of page

Move grid lines: Move a grid line with the mouse. (You can also set cell sizes numerically, see below).
Duplicate grid lines: Additionally press Alt while moving a grid line.
Select grid cells: Click inside a grid cell, select additional cells with Ctrl-Click or create contiguous selections with Shift-Click. Clicking a row/column header will select the entire row/column.
Insert rows and columns: From the grid select the appropriate command or, with at least one grid cell selected, press Ctrl+Cursor-key, for example Ctrl+Cursor-up inserts a row before the selected one.
Delete rows and columns: From the grid select the appropriate command or, with an entire row or column selected, press Backspace or Del.
Move rows and columns: By the row/column headers you can move entire rows and columns.
Switch rows or columns: With any selection where exactly two different rows or columns are involved, you can switch rows or columns using the grid .

You can apply to a single selected cell or to any combination of selected cells.


Column width and row height     Top of page

A design grid's columns can be of different width and rows can be of different height. In the following discussion we focus on column width, row height works just the same.

You can define column width either as absolute value (in pixels), component-relative value (exactly the component's preferred width) or as column-relative value (same width as column xxx).
Absolute value: The column is guaranteed to be at least as wide as the defined value. If a component in that column has a preferred width greater than the specified width, the component's preferred width will be respected (see ). Most often you will set an absolute value for empty rows/columns.
Component-relative value: The column is guaranteed to be as wide as the component's preferred width. A component-relative value is specified by setting Col. width to 0 or by selecting the Component checkbox (see ). For columns/rows containing components a component-relative size is the best choice.
Column-relative value: Two (or more) columns will be of the same width and this will be the width of the widest column involved (see ). If the involved columns have different weights (see next section) they will be of the same width only if there is no need to expand for either of the columns.

With at least one cell selected, change cell width with W+Value (where Value must be an integer). To change cell height, press H+Value. To change values relative to the current value, precede Value with 'plus' (+) or 'minus' (-).


Column weight and row weight     Top of page

Weights come into play, if the design grid is inside a container (e.g. a JTabbedPane or the content pane of a JFrame) and the design grid's size is smaller than the container's size.

If no weights are defined (all weights are zero), the design grid doesn't fill the container (see ).
As you set Col. weight to a value > 0, the column stretches to fill the container horizontally (see ).
If you additionally set Row weight to a value > 0, the row stretches to fill the container vertically (see ).

Weight values are proportional. If more than one column/row has a weight > 0, the free space is divided proportionally among weighted columns/rows (see ).

With at least one cell selected, change column weight with C+W+Value (where Value must be an integer). To change row weight, press R+W+Value. To change values relative to the current value, precede Value with 'plus' (+) or 'minus' (-).

Tip: Pressing <Q> the cell weights of the currently displayed container, pressing <Q> again shows cell weights of sub-containers. Clicking in the editor clears the display.


Column weight usage and row weight usage     Top of page

There are three : Enlarge and fit, Enlarge only, Fit multicolumns/multirows only. The default is Enlarge and fit and should suit your needs in nearly all situations (in "The RADi Tutorial" weight usage modes are discussed more deeply).


Size modes     Top of page

There are three size modes which affect the display size of a design grid:
Minimum size: Is calculated from the minimum size of all components in the grid.
Preferred size: Is calculated from the preferred size of all components in the grid. This is also the size of a pack()'ed frame.
Fixed size: Draws a border around the design grid which you can adjust similar to a frame border (indeed this is to simulate a frame). At 'Grid | Fixed Size' you can set the border size .

See also:
Component handling
Cell component parameters
Containers in grid cells
Shortcuts
Testing a layout's resizing behaviour