

The reason I like this method is because you can adjust each individual row as you like it. Now if you want to get more finite in spacing etc you can by all means use a different layout to control down to a more hardset level. Next you can define new JPanels for each individual row and just use a regular old flow layout and allow the layout manage to handle those. For this first JPanel you will declare it as a GridLayout 4 rows tall by 1 column across. One way that I can say to design this would be to create the JFrame and add a JPanel into the JFrame. WithdrawButton = new JButton("Withdraw") Ĭlass WithdrawListener implements void actionPerformed(ActionEvent event)ĭouble withdrawl = Double.parseDouble(withdrawField.getText()) ĪctionListener w = new WithdrawListener() Implement action listener for withdraw button tText("New Balance: " + result) ĪctionListener d = new DepositListener() Create deposit button and assign an action listenerĬlass DepositListener implements void actionPerformed(ActionEvent event)ĭouble depositAmount = Double.parseDouble(depositField.getText()) WithdrawField = new JTextField(FIELD_WIDTH) WithdrawLabel = new JLabel("Withdraw: ") InitialLabel = new JLabel("Initial Balance £" + INITIAL_BALANCE) ĭepositField = new JTextField(FIELD_WIDTH) ResultLabel = new JLabel("New Balance: £" + account.getBalance())


Private static final double INITIAL_BALANCE = 0.00 Private static final int FRAME_HEIGHT = 250 Private static final int FRAME_WIDTH = 300 What layout would be best to use for what I want? package assignment I've tried using different layouts but I can't get them to work and i'm not great with them. Basically I want initial balance, deposit label&field and withdraw label&field to be on different rows if that makes sense. The image above is a screenshot of my bank account GUI.
