The code for my first (wrong) FormLayout, as shown in Figure 2, is shown below. Note that at this point I'm not showing all the code for my class. I'm just trying to show the code relevant to building my JPanel for this JDialog.
private JPanel buildProjectEditPanel() { FormLayout layout = new FormLayout("30px, 2dlu, pref, 2dlu, pref", "p,3dlu,p,9dlu,p,3dlu,p,3dlu,p,3dlu,p,3dlu,pref,3dlu,p,9dlu,p"); PanelBuilder builder = new PanelBuilder(layout); builder.setDefaultDialogBorder(); CellConstraints cc = new CellConstraints(); //row 1 builder.add(lblImage, cc.xy(1,1)); builder.add(lblHeader, cc.xyw(3,1,3)); builder.add(lblHelpText, cc.xyw(3,3,3,"left,top")); builder.add(lblProjectName, cc.xy(3,5)); builder.add(txtProjectName, cc.xy(5,5)); lblProjectName.setLabelFor(txtProjectName); builder.add(lblProjectType, cc.xy(3,7)); builder.add(cboProjectType, cc.xy(5,7)); lblProjectType.setLabelFor(cboProjectType); builder.add(lblProductionFacility, cc.xy(3,9)); builder.add(cboProductionFacility, cc.xy(5,9)); lblProductionFacility.setLabelFor(cboProductionFacility); builder.add(lblTestConfig, cc.xy(3,13,"left, top")); builder.add(projectScrollPane, cc.xy(5,13)); JPanel pnlSaveCancelButtons = ButtonBarFactory.buildOKCancelBar(btnSave,btnCancel); builder.add(pnlSaveCancelButtons, cc.xy(5,15,"left, center")); return builder.getPanel(); }
As mentioned, this code is bad, or at least a part of it is. The code that ends up being wrong are these lines:
FormLayout layout = new FormLayout("30px, 2dlu, pref, 2dlu, pref", "p,3dlu,p,9dlu,p,3dlu,p,3dlu,p,3dlu,p,3dlu,pref,3dlu,p,9dlu,p");
<<Previous: Introduction |
Next: Fixing the grow and fill sizing problems>> |