Try doing something like this instead of using a single actionPerformed()
method:
Register event handler first (you missed this step):
depositButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
handleDepositButtonEvent(evt);
}
});
Implement custom event handler for that event:
private void handleDepositButtonEvent(ActionEvent evt){
double dp = Double.parseDouble(amountTextField.getText());
double dpamount = account.getBalance() + dp;
account.deposit(dpamount);
result = dpamount;
resultLabel.setText("" + result);
}
Do that for each button and component generating events you want to capture; separate action methods are easier to read and maintain.
By the way, don't add the action listener in the action listener! This makes no sense, and it won't work anyway.
if (source == depositButton) {
double dp = Double.parseDouble(amountTextField.getText());
...
depositButton.addActionListener(this); //<--- don't do this
}