title: GridBagLayout: how to fill all empty spaces
body: <p>I've have a JFrame contains some JPanels using a gridBagLayout (3 rows, one column). That's my code:</p>
  
  <pre><code>Container main_container = getContentPane();
  GridBagLayout layout = new GridBagLayout();
  main_container.setLayout(layout);
  GridBagConstraints c = new GridBagConstraints();
  
  StatoMagazzini jpanel_stato_magazzini = new StatoMagazzini();
  c.gridx = 1;
  c.gridy = 2;
  c.fill = GridBagConstraints.BOTH;
  layout.setConstraints(jpanel_stato_magazzini, c);
  
  AcquistoLotto jpanel_acquisto = new AcquistoLotto(i, jpanel_stato_magazzini);
  c.gridx = 1;
  c.gridy=1;
  c.fill = GridBagConstraints.HORIZONTAL;
  c.anchor = GridBagConstraints.FIRST_LINE_START;
  layout.setConstraints(jpanel_acquisto, c);
  
  ButtonPanel jpanel_button_panel = new ButtonPanel(i);
  c.gridx=1;
  c.gridy=3;
  c.anchor = GridBagConstraints.CENTER;
  layout.setConstraints(jpanel_button_panel, c);
  
  main_container.add(jpanel_acquisto);
  main_container.add(jpanel_stato_magazzini);
  main_container.add(jpanel_button_panel);
  pack();
  </code></pre>
  
  <p>and that's the result (a ugly result):  <a href="https://docs.google.com/file/d/0Bxi2arJ2Dv9xbEo0Smd5QUN4UGc/edit?usp=sharing" rel="noreferrer">https://docs.google.com/file/d/0Bxi2arJ2Dv9xbEo0Smd5QUN4UGc/edit?usp=sharing</a></p>
  
  <p>i would eliminate that empty spaces on top and extend the second component (that is a scrollable JTable). How i should modify code?</p>