The goal of the group layout manager is to make it easy to create professional cross platform layouts. It is designed for GUI builders, such as JFormDesigner, to use the "Free Design" paradigm. You can lay out your forms by simply placing components where you want them. Visual guidelines suggest optimal spacing, alignment and resizing of components.
GroupLayout has been developed by the NetBeans team and is also used by the NetBeans GUI Builder (formerly Project Matisse). They provide a comprehensive tutorial on designing GUIs using GroupLayout, which is also suitable for JFormDesigner: http://www.netbeans.org/kb/60/java/quickstart-gui.html
GroupLayout is part of the
standard Java distribution since Java 6. If you need to run your
application also on Java 5 or 1.4, you can use the open-source Swing Layout Extension
library, which is compatible to the Java 6 GroupLayout, but uses
different package names. Change the option "GroupLayout Generation
Style" in the Layout
Managers (Java Code Generator) preferences if necessary.
The API documentation is available here: doc.formdev.com/grouplayout/.
IDE plug-ins: If you use GroupLayout from the Swing Layout Extension
library the first time, the JFormDesigner IDE plug-in ask you
whether it should copy the required library (and its source code and
documentation) to the IDE project and add it to the classpath of the
IDE project.
Alignment guidelines appear only when adding or moving components. They indicate the preferred positions to which components snap when releasing the mouse button.
Insets are the preferred spacings between components and their container.
Offsets are the preferred spacings between adjacent components.
Baseline alignment is the preferred relationship between adjacent components that display text.
Edge alignments (top, bottom, left and right) are possible relationships between adjacent components.
Indentation alignment is a special alignment relationship in which one component is located below another and offset slightly to the right.
Anchoring indicators appear when components have snapped into position. They illustrate the alignment and relationship among components.
Anchors connecting components to their container or to adjacent components are represented by small semi-circular indicators with dashed lines.
The designer context menu provides following GroupLayout specific commands:
Command | Description | |
---|---|---|
![]() ![]() ![]() ![]() ![]() ![]() |
Align in column/row | Aligns the selected components left/right/top/bottom/center in column/row. |
![]() ![]() ![]() ![]() |
Align | Aligns the selected components left/right/top/bottom. |
![]() ![]() ![]() ![]() |
Anchor | Changes the anchoring of the selected components. A component is usually horizontally anchored left/right and vertically anchored top/bottom. Anchoring connects a component to a container edge or a neighborhood component edge. |
![]() |
Horizontal Auto Resizing | Makes the selected components resize horizontally at runtime if the container size changes. |
![]() |
Vertical Auto Resizing | Makes the selected components resize vertically at runtime if the container size changes. |
![]() |
Same Width | Makes the selected components all
the same width. If one of the selected components is already in a group
of "Same Width" components, the other components are added to the
existing group. To remove components from a group, select them and then
execute this command. Grouped components are marked with a small
indicator.![]() |
![]() |
Same Height | Makes the selected components all the same height. See "Save Width" command for more details. |
Set Default Size | Makes the selected components have its default size. | |
Space Around Component | Changes the empty space around the selected component. | |
Duplicate | Duplicates the selected components and places the new components below the original components. Use Ctrl+Left, Ctrl+Right, Ctrl+Up or Ctrl+Down keys to place the duplicated components left, right, above or below the original components. |
A container with this layout manager has following layout manager properties:
Property Name | Description | Default |
---|---|---|
honors visibility | Specifies whether component visibility is considered when positioning and sizing components. If true, non-visible components are not treated as part of the layout. If false, components are positioned and sized regardless of visibility. | true |
A component contained in a container with this layout manager has following layout constraints properties:
Property Name | Description | Default |
---|---|---|
horizontal size | Specifies the component's horizontal size in pixel or Default. If set to Default, the component's preferred width is used. | Default |
vertical size | Specifies the component's vertical size in pixel or Default. If set to Default, the component's preferred height is used. | Default |
horizontal resizable | Specifies whether the component is horizontal resizable. | false |
vertical resizable | Specifies whether the component is vertical resizable. | false |
top space | Specifies the top empty space. | |
left space | Specifies the left empty space. | |
bottom space | Specifies the bottom empty space. | |
right space | Specifies the right empty space. | |
top space resizable | Specifies whether the top empty space is vertical resizable. | false |
left space resizable | Specifies whether the left empty space is horizontal resizable. | false |
bottom space resizable | Specifies whether the bottom empty space is vertical resizable. | false |
right space resizable | Specifies whether the right empty space is horizontal resizable. | false |