Class GroupLayout

java.lang.Object
vaadinx.swing.GroupLayout
All Implemented Interfaces:
CssEmittingLayoutManager, LayoutManager, LayoutManager2

public class GroupLayout extends Object implements LayoutManager2, CssEmittingLayoutManager
Emulator for GroupLayout (D_grouplayout) — the layout manager NetBeans' GUI builder ("Free Design") emits in every generated initComponents(). Without it the import-swap of any NetBeans-built panel fails to compile (the reference to javax.swing.GroupLayout swaps to vaadinx.swing.GroupLayout); it is therefore a hard prerequisite for migrating real-world Swing rather than a runtime nicety. Built alongside GridLayout ([D_gridlayout]) as the two layout managers the first real JLawyer slice (InvoicePositionEntryPanel) forced.

Auto-add. NetBeans-generated code never calls container.add(comp) — GroupLayout adds referenced components to the host itself. So does this emulator: GroupLayout.Group.addComponent(Component) routes through autoAdd(Component), which adds the component to the host Container exactly once (each component is referenced in both the horizontal and vertical group trees, so the add is idempotent via a managed-set guard). The host's peer-DOM insertion happens through Container.add; grid placement is written later at LayoutManager.layoutContainer(Container).

Rendering — grid reconstruction (R_layouts_close_enough). GroupLayout positions each component independently on two axes (the setHorizontalGroup(GroupLayout.Group) tree and the setVerticalGroup(GroupLayout.Group) tree), every managed component appearing once in each. The emulator flattens each axis tree into integer track intervals and emits a CSS grid: a SequentialGroup lays its children in consecutive slots; a ParallelGroup overlays its children into the same slot band (its direct component children stretch to fill the band, matching GroupLayout's "all parallel children share the group's span"). Gaps consume no track — a single uniform container gap approximates their spacing. Each component is placed with grid-column/grid-row spanning its two bands, and justify-self/align-self from the effective alignment of the nearest enclosing parallel group (per-component GroupLayout.Alignment override winning). This reproduces the dominant NetBeans idiom (a vertical sequence of rows, each a parallel/baseline group of a few components aligned into columns by the horizontal tree) faithfully; exact per-gap pixel spacing and independent-strip widths are R_layouts_close_enough-approximate, left as pixel-accurate layout is out of scope permanently (D_pixel_layout_not_planned).

Size hints (R_layouts_close_enough). A track is flexible (minmax(0, 1fr)) when a component spanning it was added fully-resizable (max = Short.MAX_VALUE); otherwise the track is auto (content-sized), which keeps forms compact and label columns tight. Explicit preferred-pixel sizes (e.g. addComponent(c, PREFERRED_SIZE, 120, PREFERRED_SIZE)) are not written as hard CSS widths — that would fight the field surrogates' own columns-derived width; the auto track sizes to the surrogate's intrinsic width instead.