I used **GridBagLayout**. I can't figure out how to **stretch** the Jbuttons to fill the entire panel. 

I used the following:

```
c.fill = GridBagConstraints.BOTH;

```

Any help would be greatly appreciated. I have spent much time searching for the answer but I couldn't find it. Thank so much!

Below is the code for the JFrame setup. 

```
public class Calculator extends JFrame {

JPanel panel;

private static JTextField output;

public Calculator() {

//...standard JFrame code....

    buildButtons();

    setLayout(new BorderLayout());
    output = new JTextField("0");

    add(output, BorderLayout.PAGE_START);
    add(panel, BorderLayout.CENTER);

    setVisible(true);
}

private void buildButtons() {

    panel = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH; 

    c.weightx = 0.5; // puts boxes between columns and walls.        

    // create button array
    JButton[] button = new JButton[24];

    //MC button
    button[0] = new JButton("MC");
    button[0].addActionListener(new randomListener());

    //MR button
    button[1] = new JButton("MR");
    button[1].addActionListener(new randomListener());

  //... the rest of the buttons...

    //#3
    button[22] = new JButton("3");
    button[22].addActionListener(new NumberListener());

    //Minus Sign
    button[23] = new JButton("-");
    button[23].addActionListener(new OperationListener());

    int row = 0;
    int col = 0;
    for (JButton button1 : button) {
        c.gridx = col;
        c.gridy = row;
        c.gridheight = 1;
        c.gridwidth = 1;
        c.insets = new Insets(1, 1, 1, 1);
        c.fill = GridBagConstraints.BOTH;

        col++;

        if (col == 5) {
            col = 0;
            row++;
        }
        panel.add(button1, c);
    }

    //Equals Sign
    JButton equalsButton = new JButton(String.valueOf("="));
    equalsButton.addActionListener(new EqualsListener());
    c.gridx = 4;
    c.gridy = 4;
    c.gridheight = 2;
    c.gridwidth = 1;
    c.insets = new Insets(1, 1, 1, 1);
    c.fill = GridBagConstraints.BOTH;
    panel.add(equalsButton, c);

    //#0
    JButton zeroButton = new JButton("0");
    zeroButton.addActionListener(new NumberListener());
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.insets = new Insets(1, 1, 1, 1);
    panel.add(zeroButton, c);

    // dot
    JButton doxButton = new JButton(".");
    doxButton.addActionListener(new randomListener());
    c.gridx = 2;
    c.gridy = 5;
    c.gridheight = 1;
    c.gridwidth = 1;
    c.insets = new Insets(1, 1, 1, 1);
    c.fill = GridBagConstraints.BOTH;
    panel.add(doxButton, c);

    //Plus sign
    JButton plusButton = new JButton(String.valueOf("+"));
    plusButton.addActionListener(new OperationListener());
    c.gridx = 3;
    c.gridy = 5;
    c.insets = new Insets(1, 1, 1, 1);
    c.fill = GridBagConstraints.BOTH;
    panel.add(plusButton, c);
}

// Imbedded main:
public static void main(String[] args) {
    new Calculator();
}
}

```