How would I add gridbag layout to my code in order for output box to span the length of gui within the border parameters provided in the following code? I have two other classes that go along with this work fine. When the GUI populates it all works except the output text box doesn't span the length of gui so that the text in text box is cut off and I want to fix this, but I don't know how to do it as I never used gridbaglayout.
Below is the image showing how the GUI is supposed to look:
The code in question is given below:
public ATMGui() {
checkingAcc = new Account(1000);
savingAcc = new Account(2000);
currentSelect = new Account(0);
atmFrame = new JFrame("Automated Teller Machine");
output = new JTextField();
panel = new JPanel();
I believe that the problem may be because I didn't completely declare the size of the output box so it only spans one grid so-to-speak whereas I want it to span both. Can someone help me decide whether I declare the grid differently in the code above or if it goes below? Also, I've read about GridBagLayout and other methods but my problem is that I'm not sure how/where to implement it here.
atmWithdraw = new JButton("Withdraw");
atmDeposit = new JButton("Deposit");
transfer = new JButton("Transfer to");
balance = new JButton("Balance");
atmWithdraw.addActionListener(this);
panel.setLayout(new GridLayout(4, 2));
panel.setBorder(BorderFactory.createEmptyBorder(15, 15, 0, 15));
panel.add(atmWithdraw, 0);
panel.add(atmDeposit, 1);
panel.add(transfer, 2);
panel.add(balance, 3);
panel.add(checking, 4);
panel.add(savings, 5);
panel.add(output, BorderLayout.LINE_END);
atmFrame.add(panel);
atmFrame.setSize(300, 175);
atmFrame.setVisible(true);