title: GridBagLayout top and bottom resizing gaps
body: <p>I have following code:</p>
  <pre><code>public Frame() {
      super();
      setVisible(true);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
      setLayout(new GridBagLayout());
      GridBagConstraints c = new GridBagConstraints();
      c.fill = GridBagConstraints.BOTH;
      c.gridx = 0;
      c.weightx = 1;
      c.weighty = 1;
      for (int i = 0; i &lt; 10; i++) {
          c.gridy = i;
          panel = new JPanel();
          panel.setBorder(BorderFactory.createLineBorder(Color.RED, 1));
          add(panel, c);
      }
  }
  </code></pre>
  <p>Resulting in following frame:<br><img src="https://i.stack.imgur.com/rYxsu.jpg" alt="following" /></p>
  <p>Due to resizing (intended) you can see there is some space above and below the top and bottom element(marked by arrows).</p>
  <p>Any idea how to get rid of both empty spaces or at the very least the top one?<br>
  Thanks</p>
  <p>ps: i'm aware this question is similar to a previous question of mine however it is not the same!</p>