title: JPanel and custom Class extending JPanel not displaying correctly
body: <p>I came across a slight bug when extracting hefty parts of code from my main GUI class and putting them into smaller manageable classes.</p>
  
  <p>So I did another test with a very simple GUI and found that the same bug happens there even though the only difference is that the code is in a different location.</p>
  
  <p>The first JPanel displays correctly and fills the entire layout.
  The second TestPanel that extends JPanel does not display correctly and fills a very small portion of the layout.</p>
  
  <p><img src="https://i.stack.imgur.com/3ukUr.png" alt="The working JPanel containing JScrollPane with a JTextArea in it&#39;s viewport">
  <img src="https://i.stack.imgur.com/79lA3.png" alt="The non working JPanel containing JScrollPane with a JTextArea in it&#39;s viewport"></p>
  
  <p>Both classes have exactly the same GridBagLayout and both JScrollPanes have the same GridBagConstraints.</p>
  
  <p>Here is my main class with an JTabbedPane containing two JPanels containing one JScrollPane each with a JTextArea in it's viewport.</p>
  
  <pre><code>import java.awt.EventQueue;
  import javax.swing.JFrame;
  import javax.swing.JTabbedPane;
  import javax.swing.SwingConstants;
  import java.awt.BorderLayout;
  import javax.swing.JPanel;
  import java.awt.GridBagLayout;
  import javax.swing.JScrollPane;
  import java.awt.GridBagConstraints;
  import javax.swing.JTextArea;
  
  public class TestMainGUI
  {
      private JFrame frame;
      private JTabbedPane tabbedPane;
      private JPanel workingDefaultPanel;
      private JScrollPane workingDefaultScrollPane;
      private JTextArea workingDefaultJTextArea;
      private TestJPanel notWorkingExtendingJPanel;
  
      public static void main(String[] args)
      {
          EventQueue.invokeLater(new Runnable()
          {
              @Override
              public void run()
              {
                  try
                  {
                      TestMainGUI window = new TestMainGUI();
                      window.frame.setVisible(true);
                  }
                  catch (Exception e)
                  {
                      e.printStackTrace();
                  }
              }
          });
      }
  
      public TestMainGUI()
      {
          initialize();
      }
  
      private void initialize()
      {
          frame = new JFrame();
          frame.setBounds(100, 100, 450, 300);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          //******************************************************************//
          tabbedPane = new JTabbedPane(SwingConstants.TOP);
          frame.getContentPane().add(tabbedPane, BorderLayout.CENTER);
          //******************************************************************//
          workingDefaultPanel = new JPanel();
          tabbedPane.addTab("Working Panel", null, workingDefaultPanel, null);
          GridBagLayout gbl_WorkingDefaultPanel = new GridBagLayout();
          gbl_WorkingDefaultPanel.columnWidths = new int[]{0, 0};
          gbl_WorkingDefaultPanel.rowHeights = new int[]{0, 0};
          gbl_WorkingDefaultPanel.columnWeights = new double[]{1.0, Double.MIN_VALUE};
          gbl_WorkingDefaultPanel.rowWeights = new double[]{1.0, Double.MIN_VALUE};
          workingDefaultPanel.setLayout(gbl_WorkingDefaultPanel);
          //******************************************************************//
          workingDefaultScrollPane = new JScrollPane();
          GridBagConstraints gbc_scrollPane = new GridBagConstraints();
          gbc_scrollPane.fill = GridBagConstraints.BOTH;
          gbc_scrollPane.gridx = 0;
          gbc_scrollPane.gridy = 0;
          workingDefaultPanel.add(workingDefaultScrollPane, gbc_scrollPane);
          //******************************************************************//
          workingDefaultJTextArea = new JTextArea();
          workingDefaultScrollPane.setViewportView(workingDefaultJTextArea);
          //******************************************************************//
          notWorkingExtendingJPanel = new TestJPanel();
          tabbedPane.addTab("Non Working Panel", null, notWorkingExtendingJPanel, null);
          GridBagLayout gbl_panel_1 = new GridBagLayout();
          gbl_panel_1.columnWidths = new int[]{0, 0};
          gbl_panel_1.rowHeights = new int[]{0, 0};
          gbl_panel_1.columnWeights = new double[]{1.0, Double.MIN_VALUE};
          gbl_panel_1.rowWeights = new double[]{1.0, Double.MIN_VALUE};
          notWorkingExtendingJPanel.setLayout(gbl_panel_1);
      }
  }
  </code></pre>
  
  <p>and here is my TestJPanel</p>
  
  <pre><code>import java.awt.GridBagConstraints;
  import javax.swing.JPanel;
  import javax.swing.JScrollPane;
  import javax.swing.JTextArea;
  
  public class TestJPanel extends JPanel
  {
      private static final long serialVersionUID = 5041143050449865233L;
      private JScrollPane notWorkingJScrollPane;
      private JTextArea notWorkingJTextArea;
  
      public TestJPanel()
      {
          super();
          notWorkingJScrollPane = new JScrollPane();
          GridBagConstraints gbc_notWorkingScrollPane = new GridBagConstraints();
          gbc_notWorkingScrollPane.fill = GridBagConstraints.BOTH;
          gbc_notWorkingScrollPane.gridx = 0;
          gbc_notWorkingScrollPane.gridy = 0;
          this.add(notWorkingJScrollPane, gbc_notWorkingScrollPane);
          //******************************************************************//
          notWorkingJTextArea = new JTextArea();
          notWorkingJScrollPane.setViewportView(notWorkingJTextArea);
      }
  
      protected JScrollPane getNotWorkingJScrollPane()
      {
          return notWorkingJScrollPane;
      }
  
      protected JTextArea getNotWorkingJTextArea()
      {
          return notWorkingJTextArea;
      }
  }
  </code></pre>