Class GroupLayout
- All Implemented Interfaces:
CssEmittingLayoutManager, LayoutManager, LayoutManager2
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumPort ofjavax.swing.GroupLayout.Alignment.static classBase of the group hierarchy.static final classPort ofjavax.swing.GroupLayout.ParallelGroup.static final classPort ofjavax.swing.GroupLayout.SequentialGroup. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intUse the component's default size for the dimension.static final intUse the component's preferred size for the dimension (fixed). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLayoutComponent(String name, Component comp) voidaddLayoutComponent(Component comp, Object constraints) Per-child CSS for onechildofparent;null(the default) means the child needs none.containerCss(Container parent) Container-wide CSS forparent's peer content element (its<div>).createParallelGroup(GroupLayout.Alignment alignment) createParallelGroup(GroupLayout.Alignment alignment, boolean resizable) booleanbooleanfloatgetLayoutAlignmentX(Container target) floatgetLayoutAlignmentY(Container target) voidinvalidateLayout(Container target) voidmaximumLayoutSize(Container target) minimumLayoutSize(Container parent) preferredLayoutSize(Container parent) voidvoidvoidsetAutoCreateContainerGaps(boolean autoCreateContainerGaps) voidsetAutoCreateGaps(boolean autoCreateGaps) voidsetHonorsVisibility(boolean honorsVisibility) voidvoidtoString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface CssEmittingLayoutManager
cssLayoutName, layoutContainer
-
Field Details
-
DEFAULT_SIZE
public static final int DEFAULT_SIZEUse the component's default size for the dimension. Matches JDK's value.- See Also:
-
PREFERRED_SIZE
public static final int PREFERRED_SIZEUse the component's preferred size for the dimension (fixed). Matches JDK.- See Also:
-
-
Constructor Details
-
GroupLayout
-
-
Method Details
-
setHorizontalGroup
-
setVerticalGroup
-
createSequentialGroup
-
createParallelGroup
-
createParallelGroup
-
createParallelGroup
public GroupLayout.ParallelGroup createParallelGroup(GroupLayout.Alignment alignment, boolean resizable) -
setAutoCreateGaps
public void setAutoCreateGaps(boolean autoCreateGaps) -
getAutoCreateGaps
public boolean getAutoCreateGaps() -
setAutoCreateContainerGaps
public void setAutoCreateContainerGaps(boolean autoCreateContainerGaps) -
getAutoCreateContainerGaps
public boolean getAutoCreateContainerGaps() -
setHonorsVisibility
public void setHonorsVisibility(boolean honorsVisibility) -
linkSize
-
replace
-
addLayoutComponent
- Specified by:
addLayoutComponentin interfaceLayoutManager
-
addLayoutComponent
- Specified by:
addLayoutComponentin interfaceLayoutManager2
-
removeLayoutComponent
- Specified by:
removeLayoutComponentin interfaceLayoutManager
-
preferredLayoutSize
- Specified by:
preferredLayoutSizein interfaceLayoutManager
-
minimumLayoutSize
- Specified by:
minimumLayoutSizein interfaceLayoutManager
-
maximumLayoutSize
- Specified by:
maximumLayoutSizein interfaceLayoutManager2
-
getLayoutAlignmentX
- Specified by:
getLayoutAlignmentXin interfaceLayoutManager2
-
getLayoutAlignmentY
- Specified by:
getLayoutAlignmentYin interfaceLayoutManager2
-
invalidateLayout
- Specified by:
invalidateLayoutin interfaceLayoutManager2
-
containerCss
Description copied from interface:CssEmittingLayoutManagerContainer-wide CSS forparent's peer content element (its<div>).- Specified by:
containerCssin interfaceCssEmittingLayoutManager- Returns:
- property→value map; a
nullvalue removes the property, an absent key is left untouched.
-
childCss
Description copied from interface:CssEmittingLayoutManagerPer-child CSS for onechildofparent;null(the default) means the child needs none. Called once per child per pass, afterCssEmittingLayoutManager.containerCss(Container)(see the call-order contract).- Specified by:
childCssin interfaceCssEmittingLayoutManager
-
toString
-