FormLayout.FREE_FIELD

The two fields at the bottom have such long labels that the other labels in the column are placed too far from their fields.

The mode FormLayout.FREE_FIELD has been applied to the lengthy entries; the nice lines of fields have been slightly disturbed in exchange for all that empty space. Note that the right side of the new backorder field does not align with the right side of the "Delivery Method" field. There is no way to align these with FormLayout, other than to set the fillRightPct to 1, such that both components stretch to the right end of the column.

Panel Construction Code

m_formPanel = new FormPanel(8, 5, 8, 8);
m_formPanel.setDefaultFillRightPct(.3);
// FormPanel extends JPanel,
// has FormLayout as the default layout manager,
// and exposes all the methods of FormLayout


m_formPanel.add(new JLabel("Invoice Item ID"), new JTextField(8), 1, 1);

JComboBox productCB = new JComboBox();
productCB.addItem("Lawn Mower");
m_formPanel.add(new JLabel("Product"), productCB, 2, 1);
m_formPanel.add(new JLabel("Quantity"), new JTextField(3), 3, 1);

JComboBox deliveryCB = new JComboBox();
deliveryCB.addItem("10 Day Ground");
m_formPanel.add(new JLabel("Delivery Method"), deliveryCB, 4, 1);

//m_formPanel.add(new JLabel("Number of Items on Backorder"), new JTextField(3), 5, 1); // leaves empty space
m_formPanel.add(new JLabel("Number of Items on Backorder"), new JTextField(3), 5, 1, FormLayout.FREE_FIELD);


m_formPanel.add(new JLabel("First Name"), new JTextField(14), 1, 2);
m_formPanel.add(new JLabel("MI"), new JTextField(2), 1, 2);
m_formPanel.add(new JLabel("Last Name"), new JTextField(21), 2, 2);

m_formPanel.add(new JLabel("Street"), new JTextField(30), 3, 2);

m_formPanel.add(new JLabel("City"), new JTextField(15), 4, 2);
m_formPanel.add(new JLabel("State"), new JTextField(2), 4, 2);
m_formPanel.add(new JLabel("Zip"), new JTextField(5), 4, 2, 1);

//m_formPanel.add(new JLabel("Country (if outside the U.S.)"), new JTextField(19), 5, 2);
m_formPanel.add(new JLabel("Country (if outside the U.S.)"), new JTextField(19), 5, 2, FormLayout.FREE_FIELD);