1  import javax.swing.JLabel;
  2  import javax.swing.JTextField;
  3  import javax.swing.JFrame;
  4  import java.awt.FlowLayout;
  5  
  6  public class ShowFlowLayout extends JFrame {
  7    public ShowFlowLayout() {
  8      // Set FlowLayout, aligned left with horizontal gap 10
  9      // and vertical gap 20 between components
 10      setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
 11  
 12      // Add labels and text fields to the frame
 13      add(new JLabel("First Name"));
 14      add(new JTextField(8));
 15      add(new JLabel("MI"));
 16      add(new JTextField(1));
 17      add(new JLabel("Last Name"));
 18      add(new JTextField(8));
 19    }
 20  
 21    /** Main method */
 22    public static void main(String[] args) {
 23      ShowFlowLayout frame = new ShowFlowLayout();
 24      frame.setTitle("ShowFlowLayout");
 25      frame.setSize(200, 200);
 26      frame.setLocationRelativeTo(null); // Center the frame
 27      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 28      frame.setVisible(true);
 29    }
 30  }