title: Swing sample form application
body: <p>I have come up with the below code:</p>
  
  <pre><code>    String[] labels = {"Name: ", "Fax: ", "Email: ", "Address: "};
      int numPairs = labels.length;
  
      JFrame frame = new JFrame("SpringDemo1");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
      //Set up the content pane.
  
      Container contentPane = frame.getContentPane();
      SpringLayout layout = new SpringLayout();
      contentPane.setLayout(layout);
  
      for (int i = 0; i &lt; numPairs; i++)
      {
          JLabel lable = new JLabel(labels[i]);
          contentPane.add(lable);
          contentPane.add(new JTextField(15));
      }
      //Display the window.
      frame.pack();
      frame.setVisible(true);
  </code></pre>
  
  <p><strong>Expectation:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/QnX4l.png" alt="enter image description here"></p>
  
  <p><strong>What I am getting:</strong><br/>
  Default:</p>
  
  <p><img src="https://i.stack.imgur.com/o8Gjt.png" alt="enter image description here"></p>
  
  <hr>
  
  <p>when resized:</p>
  
  <p><img src="https://i.stack.imgur.com/Opu3q.png" alt="enter image description here"></p>
  
  <p>The result is noway related to how code actually/normally looks like!</p>
  
  <p>I also tried copy pasting and running the ready-made code: downloaded from <a href="http://docs.oracle.com/javase/tutorial/uiswing/examples/layout/SpringDemo1Project/src/layout/SpringDemo1.java" rel="nofollow noreferrer">here</a>:</p>
  
  <p>and this is how the result looks :</p>
  
  <p><img src="https://i.stack.imgur.com/AqYgU.png" alt="enter image description here"></p>