title: GridLayout throws illegal component position
body: <p>By default GridLayout(5,3) would add the components in this way:</p>
  
  <pre>A B C
  D E F
  G H I
  J K L
  M N O </pre>
  
  <p>To have the components disposed in the following positions:</p>
  
  <pre>A F K
  B G L
  C H M
  D I N
  E J O</pre>
  
  <p>I have this code:</p>
  
  <pre><code>//imports...
  
  public class GridLayoutProblem {
  
      private static final int NUM_ROWS = 5, NUM_COLMS=3;
      private JPanel mainPanel = new JPanel();
      private JPanel buttonPannel = new JPanel(new GridLayout(NUM_ROWS, NUM_COLMS));
  
      private JButton btnA = new JButton("A");
      private JButton btnB = new JButton("B");
      //same with C, D...
      private JButton btnO = new JButton("O");
  
      private JComponent[] buttons = {
              btnA, btnB, btnC, btnD, btnE,
              btnF, btnG, btnH, btnI, btnJ,
              btnK, btnL, btnM, btnN, btnO
      };
  
      public GridLayoutProblem(){
          int i=0;
          for (JComponent button : buttons){
              int index = i%NUM_ROWS*NUM_COLMS+i/NUM_ROWS;
              buttonPannel.add(button,index);
              i++;
          }
          mainPanel.add(buttonPannel);
      }
      //...
  </code></pre>
  
  <p>But it results in:
  Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: illegal component position.</p>