title: Panels overlap each other when box not big enough
body: <p>I have this gui; and when the height is not big enough the panes will overlap each other. I have to set it at least 200, so I can completely see the two rows; but when it is set at 200, then I have like a big empty row at the end, and I don't want that. How could I fix this? Thanks.</p>
  
  <pre><code>import java.awt.FlowLayout;
  import javax.swing.*;
  import java.awt.*;
  
  public class MyFrame extends JFrame {
  
      JButton panicButton;
      JButton dontPanic;
      JButton blameButton;
      JButton newsButton;
      JButton mediaButton;
      JButton saveButton;
      JButton dontSave;
  
      public MyFrame() {
          super("Crazy App");
          setSize(400, 150);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          JPanel row1 = new JPanel();
          panicButton = new JButton("Panic");
          dontPanic = new JButton("No Panic");
          blameButton = new JButton("Blame");
          newsButton = new JButton("News");
          //adding first row
          GridLayout grid1 = new GridLayout(4, 2, 10, 10);
          setLayout(grid1);
          FlowLayout flow1 = new FlowLayout(FlowLayout.CENTER, 10, 10);
          row1.setLayout(flow1);
          row1.add(panicButton);
          row1.add(dontPanic);
          row1.add(blameButton);
          row1.add(newsButton);
          add(row1);
          //adding second row
          JPanel row2 = new JPanel();
          mediaButton = new JButton("Blame");
          saveButton = new JButton("Save");
          dontSave = new JButton("No Save");
          GridLayout grid2 = new GridLayout(3, 2, 10, 10);
          setLayout(grid2);
          FlowLayout flow2 = new FlowLayout(FlowLayout.CENTER, 10, 10);
          row2.setLayout(flow2);        
          row2.add(mediaButton);
          row2.add(saveButton);
          row2.add(dontSave);
          add(row2);       
  
          setVisible(true);       
  
      }
  
      public static void main(String[] args) {
          MyFrame frame = new MyFrame();
      }   
  }
  </code></pre>