1 30 31 package com.jgoodies.forms.tutorial.building; 32 33 import javax.swing.JComponent ; 34 import javax.swing.JFrame ; 35 import javax.swing.JTextField ; 36 import javax.swing.UIManager ; 37 import javax.swing.WindowConstants ; 38 39 import com.jgoodies.forms.extras.DefaultFormBuilder; 40 import com.jgoodies.forms.layout.FormLayout; 41 42 50 51 public final class IndentColumnExample { 52 53 private JTextField fileNumberField; 54 private JTextField rfqNumberField; 55 private JTextField blNumberField; 56 private JTextField mblNumberField; 57 58 private JTextField customerKeyField; 59 private JTextField customerAddressField; 60 private JTextField shipperKeyField; 61 private JTextField shipperAddressField; 62 private JTextField consigneeKeyField; 63 private JTextField consigneeAddressField; 64 65 private JTextField departureCodeField; 66 private JTextField departurePortField; 67 private JTextField destinationCodeField; 68 private JTextField destinationPortField; 69 private JTextField deliveryDateField; 70 71 72 public static void main(String [] args) { 73 try { 74 UIManager.setLookAndFeel("com.jgoodies.plaf.plastic.PlasticXPLookAndFeel"); 75 } catch (Exception e) { 76 } 78 JFrame frame = new JFrame (); 79 frame.setTitle("Forms Tutorial :: Indent Column"); 80 frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); 81 JComponent panel = new FormDebugExample().buildPanel(); 82 frame.getContentPane().add(panel); 83 frame.pack(); 84 frame.show(); 85 } 86 87 88 90 93 private void initComponents() { 94 fileNumberField = new JTextField (); 95 rfqNumberField = new JTextField (); 96 blNumberField = new JTextField (); 97 mblNumberField = new JTextField (); 98 customerKeyField = new JTextField (); 99 customerAddressField = new JTextField (); 100 customerAddressField.setEditable(false); 101 shipperKeyField = new JTextField (); 102 shipperAddressField = new JTextField (); 103 shipperAddressField.setEditable(false); 104 consigneeKeyField = new JTextField (); 105 consigneeAddressField = new JTextField (); 106 consigneeAddressField.setEditable(false); 107 departureCodeField = new JTextField (); 108 departurePortField = new JTextField (); 109 departurePortField.setEditable(false); 110 destinationCodeField = new JTextField (); 111 destinationPortField = new JTextField (); 112 destinationPortField.setEditable(false); 113 deliveryDateField = new JTextField (); 114 } 115 116 118 121 public JComponent buildPanel() { 122 initComponents(); 123 124 FormLayout layout = new FormLayout( 125 "12dlu, pref, 3dlu, max(45dlu;min), 2dlu, min, 2dlu, min, 2dlu, min, ", 126 ""); 127 layout.setColumnGroups(new int[][] { { 4, 6, 8, 10 } }); 128 129 DefaultFormBuilder builder = new DefaultFormBuilder(layout); 130 builder.setDefaultDialogBorder(); 131 builder.setLeadingColumnOffset(1); 132 133 builder.appendSeparator("General"); 134 builder.append("File Number", fileNumberField, 7); 135 builder.append("RFQ Number", rfqNumberField, 7); 136 builder.append("BL/MBL", blNumberField, mblNumberField); builder.nextLine(); 137 138 builder.appendSeparator("Addresses"); 139 builder.append("Customer", customerKeyField, customerAddressField, 5); 140 builder.append("Shipper", shipperKeyField, shipperAddressField, 5); 141 builder.append("Consignee", consigneeKeyField, consigneeAddressField, 5); 142 143 builder.appendSeparator("Transport"); 144 builder.append("Departure", departureCodeField, departurePortField, 5); 145 builder.append("Destination", destinationCodeField, destinationPortField, 5); 146 builder.append("Delivery Date", deliveryDateField); builder.nextLine(); 147 148 return builder.getPanel(); 149 } 150 151 152 } | Popular Tags |