GroupLayout.ParallelGroup (Java Platform SE 6) (original) (raw)



javax.swing

Class GroupLayout.ParallelGroup

java.lang.Object extended by javax.swing.GroupLayout.Group extended by javax.swing.GroupLayout.ParallelGroup

Enclosing class:

GroupLayout


public class GroupLayout.ParallelGroup

extends GroupLayout.Group

A Group that aligns and sizes it's children.ParallelGroup aligns it's children in four possible ways: along the baseline, centered, anchored to the leading edge, or anchored to the trailing edge.

Baseline

A ParallelGroup that aligns it's children along the baseline must first decide where the baseline is anchored. The baseline can either be anchored to the top, or anchored to the bottom of the group. That is, the distance between the baseline and the beginning of the group can be a constant distance, or the distance between the end of the group and the baseline can be a constant distance. The possible choices correspond to the BaselineResizeBehavior constantsCONSTANT_ASCENT andCONSTANT_DESCENT.

The baseline anchor may be explicitly specified by thecreateBaselineGroup method, or determined based on the elements. If not explicitly specified, the baseline will be anchored to the bottom if all the elements with a baseline, and that are aligned to the baseline, have a baseline resize behavior ofCONSTANT_DESCENT; otherwise the baseline is anchored to the top of the group.

Elements aligned to the baseline are resizable if they have have a baseline resize behavior of CONSTANT_ASCENT orCONSTANT_DESCENT. Elements with a baseline resize behavior of OTHER or CENTER_OFFSET are not resizable.

The baseline is calculated based on the preferred height of each of the elements that have a baseline. The baseline is calculated using the following algorithm:max(maxNonBaselineHeight, maxAscent + maxDescent), where themaxNonBaselineHeight is the maximum height of all elements that do not have a baseline, or are not aligned along the baseline.maxAscent is the maximum ascent (baseline) of all elements that have a baseline and are aligned along the baseline. maxDescent is the maximum descent (preferred height - baseline) of all elements that have a baseline and are aligned along the baseline.

A ParallelGroup that aligns it's elements along the baseline is only useful along the vertical axis. If you create a baseline group and use it along the horizontal axis anIllegalStateException is thrown when you askGroupLayout for the minimum, preferred or maximum size or attempt to layout the components.

Elements that are not aligned to the baseline and smaller than the size of the ParallelGroup are positioned in one of three ways: centered, anchored to the leading edge, or anchored to the trailing edge.

Non-baseline ParallelGroup

ParallelGroups created with an alignment other thanBASELINE align elements that are smaller than the size of the group in one of three ways: centered, anchored to the leading edge, or anchored to the trailing edge.

The leading edge is based on the axis and ComponentOrientation. For the vertical axis the top edge is always the leading edge, and the bottom edge is always the trailing edge. When the ComponentOrientation is LEFT_TO_RIGHT, the leading edge is the left edge and the trailing edge the right edge. A ComponentOrientation ofRIGHT_TO_LEFT flips the left and right edges. Child elements are aligned based on the specified alignment the element was added with. If you do not specify an alignment, the alignment specified for the ParallelGroup is used.

To align elements along the baseline you createBaselineGroup, or createParallelGroup with an alignment of BASELINE. If the group was not created with a baseline alignment, and you attempt to add an element specifying a baseline alignment, anIllegalArgumentException is thrown.

Since:

1.6

See Also:

GroupLayout.createParallelGroup(), [GroupLayout.createBaselineGroup(boolean,boolean)](../../javax/swing/GroupLayout.html#createBaselineGroup%28boolean, boolean%29)


Method Summary
GroupLayout.ParallelGroup addComponent(Component component) Adds a Component to this Group.
GroupLayout.ParallelGroup [addComponent](../../javax/swing/GroupLayout.ParallelGroup.html#addComponent%28java.awt.Component, javax.swing.GroupLayout.Alignment%29)(Component component,GroupLayout.Alignment alignment) Adds a Component to this ParallelGroup with the specified alignment.
GroupLayout.ParallelGroup [addComponent](../../javax/swing/GroupLayout.ParallelGroup.html#addComponent%28java.awt.Component, javax.swing.GroupLayout.Alignment, int, int, int%29)(Component component,GroupLayout.Alignment alignment, int min, int pref, int max) Adds a Component to this ParallelGroup with the specified alignment and size.
GroupLayout.ParallelGroup [addComponent](../../javax/swing/GroupLayout.ParallelGroup.html#addComponent%28java.awt.Component, int, int, int%29)(Component component, int min, int pref, int max) Adds a Component to this Group with the specified size.
GroupLayout.ParallelGroup addGap(int pref) Adds a rigid gap to this Group.
GroupLayout.ParallelGroup [addGap](../../javax/swing/GroupLayout.ParallelGroup.html#addGap%28int, int, int%29)(int min, int pref, int max) Adds a gap to this Group with the specified size.
GroupLayout.ParallelGroup [addGroup](../../javax/swing/GroupLayout.ParallelGroup.html#addGroup%28javax.swing.GroupLayout.Alignment, javax.swing.GroupLayout.Group%29)(GroupLayout.Alignment alignment,GroupLayout.Group group) Adds a Group to this ParallelGroup with the specified alignment.
GroupLayout.ParallelGroup addGroup(GroupLayout.Group group) Adds a Group to this Group.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, [wait](../../java/lang/Object.html#wait%28long, int%29)
Method Detail

addGroup

public GroupLayout.ParallelGroup addGroup(GroupLayout.Group group)

Adds a Group to this Group.

Overrides:

[addGroup](../../javax/swing/GroupLayout.Group.html#addGroup%28javax.swing.GroupLayout.Group%29) in class [GroupLayout.Group](../../javax/swing/GroupLayout.Group.html "class in javax.swing")

Parameters:

group - the Group to add

Returns:

this Group


addComponent

public GroupLayout.ParallelGroup addComponent(Component component)

Adds a Component to this Group.

Overrides:

[addComponent](../../javax/swing/GroupLayout.Group.html#addComponent%28java.awt.Component%29) in class [GroupLayout.Group](../../javax/swing/GroupLayout.Group.html "class in javax.swing")

Parameters:

component - the Component to add

Returns:

this Group


addComponent

public GroupLayout.ParallelGroup addComponent(Component component, int min, int pref, int max)

Adds a Component to this Group with the specified size.

Overrides:

[addComponent](../../javax/swing/GroupLayout.Group.html#addComponent%28java.awt.Component, int, int, int%29) in class [GroupLayout.Group](../../javax/swing/GroupLayout.Group.html "class in javax.swing")

Parameters:

component - the Component to add

min - the minimum size or one of DEFAULT_SIZE orPREFERRED_SIZE

pref - the preferred size or one of DEFAULT_SIZE orPREFERRED_SIZE

max - the maximum size or one of DEFAULT_SIZE orPREFERRED_SIZE

Returns:

this Group


addGap

public GroupLayout.ParallelGroup addGap(int pref)

Adds a rigid gap to this Group.

Overrides:

[addGap](../../javax/swing/GroupLayout.Group.html#addGap%28int%29) in class [GroupLayout.Group](../../javax/swing/GroupLayout.Group.html "class in javax.swing")

Parameters:

pref - the size of the gap

Returns:

this Group


addGap

public GroupLayout.ParallelGroup addGap(int min, int pref, int max)

Adds a gap to this Group with the specified size.

Overrides:

[addGap](../../javax/swing/GroupLayout.Group.html#addGap%28int, int, int%29) in class [GroupLayout.Group](../../javax/swing/GroupLayout.Group.html "class in javax.swing")

Parameters:

min - the minimum size of the gap

pref - the preferred size of the gap

max - the maximum size of the gap

Returns:

this Group


addGroup

public GroupLayout.ParallelGroup addGroup(GroupLayout.Alignment alignment, GroupLayout.Group group)

Adds a Group to this ParallelGroup with the specified alignment. If the child is smaller than theGroup it is aligned based on the specified alignment.

Parameters:

alignment - the alignment

group - the Group to add

Returns:

this ParallelGroup

Throws:

[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang") - if alignment isnull


addComponent

public GroupLayout.ParallelGroup addComponent(Component component, GroupLayout.Alignment alignment)

Adds a Component to this ParallelGroup with the specified alignment.

Parameters:

alignment - the alignment

component - the Component to add

Returns:

this Group

Throws:

[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang") - if alignment isnull


addComponent

public GroupLayout.ParallelGroup addComponent(Component component, GroupLayout.Alignment alignment, int min, int pref, int max)

Adds a Component to this ParallelGroup with the specified alignment and size.

Parameters:

alignment - the alignment

component - the Component to add

min - the minimum size

pref - the preferred size

max - the maximum size

Returns:

this Group

Throws:

[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang") - if alignment isnull



Submit a bug or feature
For further API reference and developer documentation, see Java SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright © 1993, 2015, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.

Scripting on this page tracks web page traffic, but does not change the content in any way.