title: Placing swing components one below other using for loop?
body: <pre><code>    //creating two lists of gui components
      ArrayList&lt;JLabel&gt; labelList = new ArrayList&lt;JLabel&gt;();
      ArrayList&lt;JTextField&gt; textFieldList = new ArrayList&lt;JTextField&gt;();
  
      //number of labels and textfields i want to add
      int numOfAt = Data.getInstance().getInstances().numAttributes();
  
      //for loop, for adding these components
      for (int i = 0; i &lt; numOfAt - 1; i++) {
          String name = Data.getInstance().getInstances().attribute(i).name();
          labelList.add(new JLabel(name));
          labelList.get(i).setText(name);
  
          textFieldList.add(new JTextField());
  
          add(labelList.get(i));
  
          add(textFieldList.get(i));
          textFieldList.get(i).setSize(55, 25);
      }
  </code></pre>
  
  <p>These code works. Labels and fields is added on my jPanel. But i can't find solution how to place them one below other. jLabel and jTextField is placed next on each other on the first iteration of for loop. I want on second iteration, next two components to place below first two components. I'm using flow layout. </p>