Created
January 30, 2016 21:40
-
-
Save codenameone/f261e3fc0018cab63991 to your computer and use it in GitHub Desktop.
Sample using the group layout in Codename One generated by the NetBeans GUI builder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Form hi = new Form("GroupLayout"); | |
Label label1 = new Label(); | |
Label label2 = new Label(); | |
Label label3 = new Label(); | |
Label label4 = new Label(); | |
Label label5 = new Label(); | |
Label label6 = new Label(); | |
Label label7 = new Label(); | |
label1.setText("label1"); | |
label2.setText("label2"); | |
label3.setText("label3"); | |
label4.setText("label4"); | |
label5.setText("label5"); | |
label6.setText("label6"); | |
label7.setText("label7"); | |
GroupLayout layout = new GroupLayout(hi.getContentPane()); | |
hi.setLayout(layout); | |
layout.setHorizontalGroup( | |
layout.createParallelGroup(GroupLayout.LEADING) | |
.add(layout.createSequentialGroup() | |
.addContainerGap() | |
.add(layout.createParallelGroup(GroupLayout.LEADING) | |
.add(layout.createSequentialGroup() | |
.add(label1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) | |
.addPreferredGap(LayoutStyle.RELATED) | |
.add(layout.createParallelGroup(GroupLayout.LEADING) | |
.add(label4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) | |
.add(label3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) | |
.add(label2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) | |
.add(label5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) | |
.add(layout.createSequentialGroup() | |
.add(label6, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) | |
.addPreferredGap(LayoutStyle.RELATED) | |
.add(label7, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) | |
.addContainerGap(296, Short.MAX_VALUE)) | |
); | |
layout.setVerticalGroup( | |
layout.createParallelGroup(GroupLayout.LEADING) | |
.add(layout.createSequentialGroup() | |
.addContainerGap() | |
.add(layout.createParallelGroup(GroupLayout.TRAILING) | |
.add(label2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) | |
.add(label1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) | |
.addPreferredGap(LayoutStyle.RELATED) | |
.add(label3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) | |
.addPreferredGap(LayoutStyle.RELATED) | |
.add(label4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) | |
.addPreferredGap(LayoutStyle.RELATED) | |
.add(label5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) | |
.addPreferredGap(LayoutStyle.RELATED) | |
.add(layout.createParallelGroup(GroupLayout.LEADING) | |
.add(label6, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) | |
.add(label7, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) | |
.addContainerGap(150, Short.MAX_VALUE)) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample usage code for GroupLayout
Most of this code was generated by the NetBeans GUI builder and adapted to the Codename One project