title: JScrollPane collapses after resizing JFrame
body: <p>I'm having trouble with some <code>LayoutManager</code> issues (I believe). I'm working on a little project for my own, and i have replicated my problem below. The problem is that when I make the window  even a pixel smaller (in x or y direction, doesn't matter) than the original size the whole <code>JScrollPane</code> collapses, to the point that the table it is no longer visible.</p>
  
  <p>I Want the <code>JPanel</code> to re-size according to the <code>JFrame</code>, without the <code>JScrollPane</code> collapsing. I've added color to the borders to illustrate the problem.</p>
  
  <p>I have looked up all sorts of questions to solve this issue, but the answers vary a lot and I have found no suitable solution for my problem. I have a general understanding of LayoutManagers but clearly not extensive enough to figure this one out. Thank you for any help in advance.</p>
  
  <p>Frame normal:</p>
  
  <p><img src="https://i.stack.imgur.com/J46Fm.png" alt="Frame normal"></p>
  
  <p>Frame smaller (Collapsed / Disappeared table):</p>
  
  <p><img src="https://i.stack.imgur.com/J9Fpu.png" alt="Frame smaller"></p>
  
  <p>Frame larger (No problems):</p>
  
  <p><img src="https://i.stack.imgur.com/V5TqX.png" alt="Frame larger"></p>
  
  <p>Code (SSCCE):</p>
  
  <pre><code>import java.awt.BorderLayout;
  import java.awt.Color;
  import java.awt.Dimension;
  import java.awt.GridBagConstraints;
  import java.awt.GridBagLayout;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  
  import javax.swing.BorderFactory;
  import javax.swing.JButton;
  import javax.swing.JFrame;
  import javax.swing.JMenu;
  import javax.swing.JMenuBar;
  import javax.swing.JMenuItem;
  import javax.swing.JPanel;
  import javax.swing.JScrollPane;
  import javax.swing.JTable;
  import javax.swing.UIManager;
  import javax.swing.UnsupportedLookAndFeelException;
  
  
  public class MainWindow extends JFrame {
  
      private JPanel EmployeePanel;
      private JButton add, remove, edit;
      private JTable EmployeeTable;
      private JScrollPane EmployeeTableScrollPane;
  
      private JMenuBar menu;
      private JMenu file;
      private JMenuItem exit;
  
      private String[] columns = {"First Name", "Last Name", "Initials"};
      private String[][] data = {
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"},
              {"First Name", "Last Name", "Initials"}
              };
  
  
  
      public MainWindow(){
          //Set title
          super("Scheduler");
  
          //Set LaF
          try {
              UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
          } catch (ClassNotFoundException | InstantiationException
                  | IllegalAccessException | UnsupportedLookAndFeelException e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
          }
  
          //Set JFrame properties
          this.setSize(new Dimension(800,600));
          this.setMinimumSize(new Dimension(300,300));
          this.setDefaultCloseOperation(EXIT_ON_CLOSE);
          this.setLocationRelativeTo(null);
          this.setVisible(true);
          this.setLayout(new BorderLayout());
  
          //Initialize JComponents
          EmployeeTable = new JTable(data, columns){
              @Override
              public boolean isCellEditable(int row, int column) {
                  return false;
              }
          };
          EmployeeTableScrollPane = new JScrollPane(EmployeeTable);
  
          add = new JButton("Add");
          remove = new JButton("Remove");
          edit = new JButton("Edit");
  
          menu = new JMenuBar();
          file = new JMenu("File");
          exit = new JMenuItem("Exit");
  
          //Set MenuBar
          file.add(exit);
          menu.add(file);
          this.setJMenuBar(menu);
  
          exit.addActionListener(new ActionListener(){
              //Don't mind the method i use for now to close the application
              @Override
              public void actionPerformed(ActionEvent arg0) {
                  System.exit(0);
              }
  
          });
  
          GridBagConstraints constraints = new GridBagConstraints();
          EmployeePanel = new JPanel(new GridBagLayout());
          //Add JScrollPane
          constraints.weightx = 1;
          constraints.weighty = 1;
          constraints.gridx = 0;
          constraints.gridy = 0;
          constraints.gridwidth = 3;
          constraints.gridheight = 1;
          constraints.anchor = constraints.NORTH;
          constraints.fill = constraints.HORIZONTAL;
          EmployeePanel.add(EmployeeTableScrollPane, constraints);
  
          //Add Buttons
          constraints.gridx = 0;
          constraints.gridy = 1;
          constraints.gridwidth = 1;
          constraints.gridheight = 1;
          constraints.anchor = constraints.SOUTH;
          constraints.fill = constraints.HORIZONTAL;
          EmployeePanel.add(add, constraints);
  
          constraints.gridx = 1;
          constraints.gridy = 1;
          constraints.gridwidth = 1;
          constraints.gridheight = 1;
          constraints.anchor = constraints.SOUTH;
          constraints.fill = constraints.HORIZONTAL;
          EmployeePanel.add(edit, constraints);
  
          constraints.gridx = 2;
          constraints.gridy = 1;
          constraints.gridwidth = 1;
          constraints.gridheight = 1;
          constraints.anchor = constraints.SOUTH;
          constraints.fill = constraints.HORIZONTAL;
          EmployeePanel.add(remove, constraints);
  
          //Add EmployeePanel
          this.add(EmployeePanel, BorderLayout.CENTER);
  
          EmployeeTableScrollPane.setBorder(BorderFactory.createLineBorder(Color.YELLOW));
          EmployeeTable.setBorder(BorderFactory.createLineBorder(Color.BLUE));
  
          this.validate();
          this.pack();
  
      }
  
      public static void main(String[] args){
          new MainWindow();
      }
  
  }
  </code></pre>