title: How to fix GridBagLayout button size
body: <pre><code>import javax.swing.JFrame;
  
  public class Main {
      private JFrame frame;
  
      /**
       * @param args
       */
      public Main() {
          frame = new JFrame();
          frame.setTitle("450");
          frame.setSize(1000, 600);
          MemberPanel memberPanel = new MemberPanel();
          frame.add(memberPanel);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setVisible(true);
      }
  
      public static void main(String[] args) {
          new Main();
      }
  
  }
  import java.awt.GridBagConstraints;
  import java.awt.GridBagLayout;
  import java.awt.Insets;
  import java.awt.TextField;
  import javax.swing.JButton;
  import javax.swing.JPanel;
  
  public class MemberPanel extends JPanel{
      private GridBagConstraints c;
  
      public MemberPanel() {
          setLayout(new GridBagLayout());
          c = new GridBagConstraints();
          memberPage();
          //memberPage2();
  
      }
      public void memberPage() {
          JButton addMovie = new JButton("Add Movie");
          JButton random = new JButton("Random");
          JButton storedData = new JButton("Stored Data");
          JButton settings = new JButton("Settings");
          JButton quit = new JButton("Quit");
          JButton search = new JButton("Search");
          TextField searchBar = new TextField(40);
          removeAll();
          repaint();
          revalidate();
          c.fill = GridBagConstraints.HORIZONTAL;
          c.ipady = 20;
          c.ipadx = 40;
          c.insets = new Insets(0, 20, 20, 0); // side padding
          c.gridx = 0;
          c.gridy = 0;
          add(addMovie, c);
          c.fill = GridBagConstraints.HORIZONTAL;
          c.ipady = 20;
          c.ipadx = 40;
          c.insets = new Insets(0, 20, 20, 0); // side padding
          c.gridx = 1;
          c.gridy = 0;
          add(random, c);
          c.fill = GridBagConstraints.HORIZONTAL;
          c.ipady = 20;
          c.ipadx = 40;
          c.insets = new Insets(0, 20, 20, 0); // side padding
          c.gridx = 2;
          c.gridy = 0;
          add(storedData, c);
          c.fill = GridBagConstraints.HORIZONTAL;
          c.ipady = 20;
          c.ipadx = 40;
          c.insets = new Insets(0, 20, 20, 0); // side padding
          c.gridx = 3;
          c.gridy = 0;
          add(settings, c);
          c.fill = GridBagConstraints.HORIZONTAL;
          c.ipady = 20;
          c.ipadx = 40;
          c.insets = new Insets(0, 20, 20, 0); // side padding
          c.gridx = 4;
          c.gridy = 0;
          add(quit, c);
          c.fill = GridBagConstraints.HORIZONTAL;
          c.ipady = 20;
          c.ipadx = 40;
          c.insets = new Insets(20, 20, 20, 20); // side padding
          c.gridx = 2;
          c.gridy = 2;
          add(searchBar, c);
          c.fill = GridBagConstraints.HORIZONTAL;
          c.ipady = 20;
          c.ipadx = 40;
          c.insets = new Insets(20, 20, 20, 20); // side padding
          c.gridx = 3;
          c.gridy = 2;
          add(search, c);
      }
      public void memberPage2(){
          JButton addMovie = new JButton("Add Movie");
          JButton random = new JButton("Random");
          JButton storedData = new JButton("Stored Data");
          JButton settings = new JButton("Settings");
          JButton quit = new JButton("Quit");
          JButton search = new JButton("Search");
          TextField searchBar = new TextField(40);
          removeAll();
          repaint();
          revalidate();
          c.fill = GridBagConstraints.HORIZONTAL;
          c.ipady = 20;
          c.ipadx = 40;
          c.insets = new Insets(0, 20, 20, 0); // side padding
          c.gridx = 0;
          c.gridy = 0;
          add(addMovie, c);
          c.fill = GridBagConstraints.HORIZONTAL;
          c.ipady = 20;
          c.ipadx = 40;
          c.insets = new Insets(0, 20, 20, 0); // side padding
          c.gridx = 1;
          c.gridy = 0;
          add(random, c);
          c.fill = GridBagConstraints.HORIZONTAL;
          c.ipady = 20;
          c.ipadx = 40;
          c.insets = new Insets(0, 20, 20, 0); // side padding
          c.gridx = 2;
          c.gridy = 0;
          add(storedData, c);
          c.fill = GridBagConstraints.HORIZONTAL;
          c.ipady = 20;
          c.ipadx = 40;
          c.insets = new Insets(0, 20, 20, 0); // side padding
          c.gridx = 3;
          c.gridy = 0;
          add(settings, c);
          c.fill = GridBagConstraints.HORIZONTAL;
          c.ipady = 20;
          c.ipadx = 40;
          c.insets = new Insets(0, 20, 20, 0); // side padding
          c.gridx = 4;
          c.gridy = 0;
          add(quit, c);
      }
  }
  </code></pre>
  
  <p>In the constructor of class <code>MemberPanel</code> there are two functions <code>memberPage()</code> and <code>memberPage2()</code>. <code>memberPage()</code> is the function that I want to implement but the size of the buttons are all wrong. I want all the buttons except <code>searchBar</code> and <code>search</code> to be the same size. To see what I mean, uncomment <code>memberPage2()</code> and comment out <code>memberPage()</code>. How do I keep all the buttons in <code>memberPage2()</code>the same size while adding my <code>searchBar</code> and <code>search</code> button and using the <code>gridBagLayout</code>?</p>