title: layout code for bank account jframe
body: <p><a href="https://i.stack.imgur.com/wlMpJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wlMpJ.jpg" alt="enter image description here"></a></p>
  
  <p>The image above is a screenshot of my bank account GUI. Basically I want initial balance, deposit label&amp;field and withdraw label&amp;field to be on different rows if that makes sense.</p>
  
  <p>I've tried using different layouts but I can't get them to work and i'm not great with them. </p>
  
  <p>What layout would be best to use for what I want?</p>
  
  <pre><code>package assignment;
  
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import javax.swing.JButton;
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  import javax.swing.JPanel;
  import javax.swing.JTextField;
  
      public class accountFrame extends JFrame 
      {
         private static final int FRAME_WIDTH = 300;
         private static final int FRAME_HEIGHT = 250;
         private static final double INITIAL_BALANCE = 0.00;
         double result;
         private JLabel initialLabel;
         private JLabel depositLabel;
         private JLabel withdrawLabel;
         private JTextField depositField;  
         private JTextField withdrawField;
         private JButton depositButton;
         private JButton withdrawButton;
         private final JLabel resultLabel;
         private JPanel controlPanel;
         private final cAccount account; 
  
  
         public accountFrame()
         { 
  
            account = new cAccount();      
            resultLabel = new JLabel("New Balance: £" + account.getBalance());
  
            createTextField();
            createButton();
            createControlPanel();
            setSize(FRAME_WIDTH, FRAME_HEIGHT);
                setLocationRelativeTo(null);
  
         }
  
         private void createTextField()
         {
            final int FIELD_WIDTH = 5;
  
            initialLabel = new JLabel("Initial Balance £" + INITIAL_BALANCE);       
            depositLabel = new JLabel("Deposit: ");
            depositField = new JTextField(FIELD_WIDTH);
                withdrawLabel = new JLabel("Withdraw: ");
                withdrawField = new JTextField(FIELD_WIDTH);
         }
  
         private void createButton()
         {
  
                 //Create deposit button and assign an action listener
            depositButton = new JButton("Deposit");
  
            class DepositListener implements ActionListener
            {
                   @Override
               public void actionPerformed(ActionEvent event)
               {     
                  double depositAmount = Double.parseDouble(depositField.getText());
  
  
                  account.deposit(depositAmount);
                  result = account.getBalance();
                  resultLabel.setText("New Balance: " + result);
                      depositField.setText("0.00");
               }           
            }
  
            ActionListener d = new DepositListener();
  
            depositButton.addActionListener(d);     
  
                //Implement action listener for withdraw button
            withdrawButton = new JButton("Withdraw");
  
            class WithdrawListener implements ActionListener
            {
                   @Override
               public void actionPerformed(ActionEvent event)
               {    
                  double withdrawl = Double.parseDouble(withdrawField.getText());
  
                      account.withdraw(withdrawl);
  
                  result = account.getBalance();
                  resultLabel.setText("New Balance: " + result);
                      withdrawField.setText("0.00");
               }           
            }
  
            ActionListener w = new WithdrawListener();
            withdrawButton.addActionListener(w);
         }
  
         private void createControlPanel()        
         {
  
            controlPanel = new JPanel();
            controlPanel.add(initialLabel);
            controlPanel.add(depositLabel);
            controlPanel.add(depositField);
            controlPanel.add(depositButton);
            controlPanel.add(withdrawLabel);
            controlPanel.add(withdrawField);
            controlPanel.add(withdrawButton);
            controlPanel.add(resultLabel);
            add(controlPanel);
         }
  
       }
  </code></pre>