When run the following is produced.
This layout consists of the following.
Sequential: | A sequential group positions its child elements sequentially, one after another. |
Parallel: | A parallel group positions its child elements in the same space on top of each other. Parallel groups can also align the child elements along their baseline. |
The following code builds a simple layout consisting of two labels in one column, followed by two textfields in the next column:
JComponent panel = ...; GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); layout.setAutocreateGaps(true); layout.setAutocreateContainerGaps(true); GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup(); hGroup.add(layout.createParallelGroup().add(label1).add(label2)). add(layout.createParallelGroup().add(tf1).add(tf2)); layout.setHorizontalGroup(hGroup); GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup(); vGroup.add(layout.createParallelGroup(GroupLayout.BASELINE).add(label1).add(tf1)). add(layout.createParallelGroup(GroupLayout.BASELINE).add(label2).add(tf2)); layout.setVerticalGroup(vGroup);
This layout consists of the following:
add
methods. add
methods of Groups
return themselves. This allows for easy chaining of invocations. For example, group.add(label1).add(label2);
is equivalent to group.add(label1);group.add(label2);
. GroupLayout
. setAutocreateGaps()
method. Similarly you can use the setAutocreateContainerGaps()
method to insert gaps between the components and the container.
@version $Revision: 1.11 $
@author Tomas Pavek
@author Jan Stola
@author Scott Violet
Sequential: | A sequential group positions its child elements sequentially, one after another. |
Parallel: | A parallel group positions its child elements in the same space on top of each other. Parallel groups can also align the child elements along their baseline. |
The following code builds a simple layout consisting of two labels in one column, followed by two textfields in the next column:
JComponent panel = ...; GroupLayout layout = new GroupLayout(panel); panel.setLayout(layout); layout.setAutocreateGaps(true); layout.setAutocreateContainerGaps(true); GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup(); hGroup.add(layout.createParallelGroup().add(label1).add(label2)). add(layout.createParallelGroup().add(tf1).add(tf2)); layout.setHorizontalGroup(hGroup); GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup(); vGroup.add(layout.createParallelGroup(GroupLayout.BASELINE).add(label1).add(tf1)). add(layout.createParallelGroup(GroupLayout.BASELINE).add(label2).add(tf2)); layout.setVerticalGroup(vGroup);
This layout consists of the following:
add
methods. add
methods of Groups
return themselves. This allows for easy chaining of invocations. For example, group.add(label1).add(label2);
is equivalent to group.add(label1);group.add(label2);
. GroupLayout
. setAutocreateGaps()
method. Similarly you can use the setAutocreateContainerGaps()
method to insert gaps between the components and the container.
@version $Revision: 1.1 $
@author Tomas Pavek
@author Jan Stola
@author Scott Violet
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|