title: Create FormLayout rows and columns dynamically (at runtime)
body: <p>Hello guys and ladies,</p>
  
  <p>as I let the Eclipse WindowBuilder create me a JPanel with a FormLayout, I wanted to make this creation to be dynamical, because the program I'm writing needs it that way in order to avoid 1000 row long from. I used the following code:</p>
  
  <pre><code>JPanel pData = new JPanel();
  pData.setBounds(10, 232, 381, 163);
  
  
  FormLayout fLayout= new FormLayout(new ColumnSpec[]{}, new RowSpec[]{});
  
  int numCols = 5;
  int numRows = 10;
  
  for(int i=1;i&lt;=numCols;i+=2)
  {
      fLayout.insertColumn(i, FormFactory.RELATED_GAP_COLSPEC);
      fLayout.insertColumn(i+1, FormFactory.DEFAULT_COLSPEC);
  }
  
  for(int j=1;j&lt;=numRows;j+=2)
  {
      fLayout.insertRow(j, FormFactory.RELATED_GAP_ROWSPEC);
      fLayout.insertRow(j+1, FormFactory.DEFAULT_ROWSPEC);
  }
  
  pData.setLayout(fLayout);
  getContentPane().add(pData);
  </code></pre>
  
  <p>But starting the program, I get a stack of errors starting with:</p>
  
  <blockquote>
    <p>"The column index 1 must be in the range [1, 0]"</p>
  </blockquote>
  
  <p>Changing the index in the for-loop(s) simply changes the number in the middle of this error text, but the rest stays the same.</p>
  
  <p>What am I doing wrong? Is it even possible to create a FormLayout dynamically? I'd really appreciate your help!</p>
  
  <p>Additional Information:
  The reason I'm using a FormLayout is the fact, the columns have different sizes. I know GridBagLayout can do so as well, but it needs many more lines and numbers to have the same result concerning insets and position. But if it's the only sensible alternative, I'll accept it ... as long as it's dynamical ;-)</p>