title: JPanel filled with Buttons inside a JScrollPane
body: <p>I'm currently trying to fill a JPanel (using GridLayout) with Buttons. These Buttons should be squares having a set width.
  The programm should be able to resize the playing field (n*m buttons). Problem is, the buttons are automatically stretched to completely fill the JScrollpane, completely ignoring the set height and width. Thus making the scrollbars unnecessary.
  Here is my code:</p>
  
  <p>Creating the panels:</p>
  
  <pre><code>panel_game = new javax.swing.JPanel();
  jScrollPane1 = new javax.swing.JScrollPane(panel_game);
  </code></pre>
  
  <p>Trying to resize the JPanel: (where x and y are the number of buttons and zoomlvl the size)</p>
  
  <pre><code>panel_game.setLayout(new java.awt.GridLayout(x, y));
  panel_game.setBounds(panel_game.getX()+5,panel_game.getY()+5,x*zoomlvl-5,y*zoomlvl);
  panel_game.setPreferredSize(new Dimension(x*zoomlvl,y*zoomlvl));  
  </code></pre>
  
  <p>And adding the buttons: (f is my playfield, a 2D-Array)(buttons is a Arraylist, containing my buttons)</p>
  
  <pre><code>for(int i=0; i&lt;f.getSize()[0]*f.getSize()[1];i++){
      buttons.add(new JButton());
      buttons.get(i).setSize(zoomlvl, zoomlvl);
      buttons.get(i).setPreferredSize(new Dimension(zoomlvl,zoomlvl));
      panel_game.add(buttons.get(i));
  } 
  </code></pre>
  
  <p>I have no clue how I can tell Java to stop resizing my buttons etc. automatically.
  Help would be appreciated :)</p>