1 30 31 package com.jgoodies.forms.tutorial.building; 32 33 import javax.swing.*; 34 35 import com.jgoodies.forms.extras.DefaultFormBuilder; 36 import com.jgoodies.forms.layout.FormLayout; 37 38 57 58 public final class DefaultFormBuilderExample { 59 60 private JTextField identifierField; 61 private JTextField ptiField; 62 private JTextField powerField; 63 private JTextField sField; 64 private JTextField daField; 65 private JTextField diField; 66 private JTextField da2Field; 67 private JTextField di2Field; 68 private JTextField rField; 69 private JTextField dField; 70 private JComboBox locationCombo; 71 private JTextField kFactorField; 72 73 74 public static void main(String [] args) { 75 try { 76 UIManager.setLookAndFeel("com.jgoodies.plaf.plastic.PlasticXPLookAndFeel"); 77 } catch (Exception e) { 78 } 80 JFrame frame = new JFrame(); 81 frame.setTitle("Forms Tutorial :: Default Form"); 82 frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); 83 JComponent panel = new DefaultFormBuilderExample().buildPanel(); 84 frame.getContentPane().add(panel); 85 frame.pack(); 86 frame.show(); 87 } 88 89 90 92 95 private void initComponents() { 96 identifierField = new JTextField(); 97 ptiField = new JTextField(); 98 powerField = new JTextField(); 99 sField = new JTextField(); 100 daField = new JTextField(); 101 diField = new JTextField(); 102 da2Field = new JTextField(); 103 di2Field = new JTextField(); 104 rField = new JTextField(); 105 dField = new JTextField(); 106 locationCombo = createLocationComboBox(); 107 kFactorField = new JTextField(); 108 } 109 110 113 private JComboBox createLocationComboBox() { 114 return new JComboBox( 115 new String [] { 116 "Propeller nut thread", 117 "Stern tube front area", 118 "Shaft taper" }); 119 } 120 121 122 124 132 public JComponent buildPanel() { 133 initComponents(); 134 135 FormLayout layout = new FormLayout( 136 "right:max(40dlu;pref), 3dlu, 70dlu, 7dlu, " 137 + "right:max(40dlu;pref), 3dlu, 70dlu", 138 ""); 139 DefaultFormBuilder builder = new DefaultFormBuilder(layout); 140 builder.setDefaultDialogBorder(); 141 142 143 builder.appendSeparator("Flange"); 144 145 builder.append("&Identifier", identifierField); 146 builder.nextLine(); 147 148 builder.append("PTI [kW]", ptiField); 149 builder.append("Power [kW]", powerField); 150 151 builder.append("s [mm]", sField); 152 builder.nextLine(); 153 154 155 builder.appendSeparator("Diameters"); 156 157 builder.append("&da [mm]", daField); 158 builder.append("di [mm]", diField); 159 160 builder.append("da2 [mm]", da2Field); 161 builder.append("di2 [mm]", di2Field); 162 163 builder.append("R [mm]", rField); 164 builder.append("D [mm]", dField); 165 166 167 builder.appendSeparator("Criteria"); 168 169 builder.append("&Location", locationCombo); 170 builder.append("k-factor", kFactorField); 171 172 return builder.getPanel(); 173 } 174 175 } | Popular Tags |