- java.lang.Object
-
- javax.swing.GroupLayout.Group
-
- Direct Known Subclasses:
- GroupLayout.ParallelGroup, GroupLayout.SequentialGroup
- Enclosing class:
- GroupLayout
public abstract class GroupLayout.Group extends Object
Group
provides the basis for the two types of operations supported byGroupLayout
: laying out components one after another (SequentialGroup
) or aligned (ParallelGroup
).Group
and its subclasses have no public constructor; to create one use one ofcreateSequentialGroup
orcreateParallelGroup
. Additionally, taking aGroup
created from oneGroupLayout
and using it with another will produce undefined results.Various methods in
Group
and its subclasses allow you to explicitly specify the range. The arguments to these methods can take two forms, either a value greater than or equal to 0, or one ofDEFAULT_SIZE
orPREFERRED_SIZE
. A value greater than or equal to0
indicates a specific size.DEFAULT_SIZE
indicates the corresponding size from the component should be used. For example, ifDEFAULT_SIZE
is passed as the minimum size argument, the minimum size is obtained from invokinggetMinimumSize
on the component. Likewise,PREFERRED_SIZE
indicates the value fromgetPreferredSize
should be used. The following example addsmyComponent
togroup
with specific values for the range. That is, the minimum is explicitly specified as 100, preferred as 200, and maximum as 300.group.addComponent(myComponent, 100, 200, 300);
The following example addsmyComponent
togroup
using a combination of the forms. The minimum size is forced to be the same as the preferred size, the preferred size is determined by usingmyComponent.getPreferredSize
and the maximum is determined by invokinggetMaximumSize
on the component.group.addComponent(myComponent, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE);
Unless otherwise specified all the methods of
Group
and its subclasses that allow you to specify a range throw anIllegalArgumentException
if passed an invalid range. An invalid range is one in which any of the values are < 0 and not one ofPREFERRED_SIZE
orDEFAULT_SIZE
, or the following is not met (for specific values):min
<=pref
<=max
.Similarly any methods that take a
Component
throw aIllegalArgumentException
if passednull
and any methods that take aGroup
throw anNullPointerException
if passednull
.- Since:
- 1.6
- See Also:
GroupLayout.createSequentialGroup()
,GroupLayout.createParallelGroup()
-
-
Method Summary
Methods Modifier and Type Method and Description GroupLayout.Group
addComponent(Component component)
Adds aComponent
to thisGroup
.GroupLayout.Group
addComponent(Component component, int min, int pref, int max)
Adds aComponent
to thisGroup
with the specified size.GroupLayout.Group
addGap(int size)
Adds a rigid gap to thisGroup
.GroupLayout.Group
addGap(int min, int pref, int max)
Adds a gap to thisGroup
with the specified size.GroupLayout.Group
addGroup(GroupLayout.Group group)
Adds aGroup
to thisGroup
.
-
-
-
Method Detail
-
addGroup
public GroupLayout.Group addGroup(GroupLayout.Group group)
Adds aGroup
to thisGroup
.- Parameters:
group
- theGroup
to add- Returns:
- this
Group
-
addComponent
public GroupLayout.Group addComponent(Component component)
Adds aComponent
to thisGroup
.- Parameters:
component
- theComponent
to add- Returns:
- this
Group
-
addComponent
public GroupLayout.Group addComponent(Component component, int min, int pref, int max)
Adds aComponent
to thisGroup
with the specified size.- Parameters:
component
- theComponent
to addmin
- the minimum size or one ofDEFAULT_SIZE
orPREFERRED_SIZE
pref
- the preferred size or one ofDEFAULT_SIZE
orPREFERRED_SIZE
max
- the maximum size or one ofDEFAULT_SIZE
orPREFERRED_SIZE
- Returns:
- this
Group
-
addGap
public GroupLayout.Group addGap(int size)
Adds a rigid gap to thisGroup
.- Parameters:
size
- the size of the gap- Returns:
- this
Group
- Throws:
IllegalArgumentException
- ifsize
is less than0
-
addGap
public GroupLayout.Group addGap(int min, int pref, int max)
Adds a gap to thisGroup
with the specified size.- Parameters:
min
- the minimum size of the gappref
- the preferred size of the gapmax
- the maximum size of the gap- Returns:
- this
Group
- Throws:
IllegalArgumentException
- if any of the values are less than0
-
-
Document created the 11/06/2005, last modified the 04/03/2020
Source of the printed document:https://www.gaudry.be/en/java-api-rf-javax/swing/grouplayout.group.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.