title: Added button isn't visible
body: <p>I try to add an extra panel to already existing one, switchable with button1, but for some reason any added elements (button1) aren't showing up. Here is the fragment of used code: </p>
  
  <pre><code>    JFrame frame = new JFrame("App");
      frame.setSize(1200, 800);
      frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
      JPanel panel = new JPanel(new GridBagLayout());
  
      JPanel mainPanel = new JPanel(new CardLayout());
      JPanel menu = new JPanel(new GridBagLayout());
      mainPanel.add(menu);
      GridBagConstraints e =  new GridBagConstraints();
      e.gridy = 0;
      e.gridx = 0;
      JButton button1 = new JButton("Catalogue");
      menu.add(button1, e);
  
      frame.add(mainPanel);
      mainPanel.add(panel);
  
      (...code....)
  
      frame.setVisible(true);
  </code></pre>