Hey guys,when i go to enter the same account number as i am logged into as well as any other account and click ok the error message displays however it does not stop me from progressing to transfer money to myself. I have had a shot at it however as i'm new and not sure what to do?

public void actionPerformed(ActionEvent e) {
        String cmd = e.getActionCommand();
        String id = passwordField.getText();  //gets "input" from text entry
        String transferaccount_id = atmData.getTransferaccount_id(id);
        String accountbalance = atmData.getAccountbalance(id);
      
        if (QUIT.equals(cmd)) { //User hits Quit button.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                  atm.loginGUI();
                  }
                });                                    
        } 
        if (CONTINUE.equals(cmd)) {
                char[] pwid = passwordField.getPassword();
                String intransferaccount_id =  new String (pwid);
   
                if  (transferaccount_id.isEmpty()) {    // Account matches return from atmData.getid_inf
                JOptionPane.showMessageDialog(controllingFrame,
                "Invalid Account Number. Try again.",
                    "Error Message",
                    JOptionPane.ERROR_MESSAGE);
               
                }else if (intransferaccount_id.equals(transferaccount_id)){
                JOptionPane.showMessageDialog(controllingFrame,
                    "The account you have selected to transfer funds to is " + atmData.getTransferaccount_id (id));
                    atm.transferamountGUI();
                   

                    if (intransferaccount_id.equals(transferaccount_id)){
                String newBalance1 = atmData.getBalance();
                    for (int i = 0; i <= lines ; i++) {
                    newBalance1 = accountbalance;
                    lineTo = i;
                    break; 
                
                }
            
             if (transferaccount_id==transferaccount_id){
                   JOptionPane.showMessageDialog(controllingFrame,
                "You cannot transfer money to yourself!. Try again.",
                    "Error Message",
                    JOptionPane.ERROR_MESSAGE);
              
                }
            
            }
        }
    }
}

as you can see i have added this method to try and stop it however it continues to progress!

if (transferaccount_id==transferaccount_id){ JOptionPane.showMessageDialog(controllingFrame,
"You cannot transfer money to yourself!. Try again.",
"Error Message",
JOptionPane.ERROR_MESSAGE);

As transferaccount_id is string then use string function to compare and thats equals function

if(name.equals("String you want to match");

hi thanks but i'm still getting the same problem =( here it is updated to the way you mentioned

if (intransferaccount_id.equals(intransferaccount_id)){
                   JOptionPane.showMessageDialog(controllingFrame,
                "You cannot transfer money to yourself!. Try again.",
                    "Error Message",
                    JOptionPane.ERROR_MESSAGE);

Use trim and upper/lower case function also because matching small string with large will always return false event the content are same, also spaces can give problem.

Still a no go =(

Looking at your posts I see

if (transferaccount_id==transferaccount_id){

and

if (intransferaccount_id.equals(intransferaccount_id)){

but in both cases you are comparing the same object to itself!
I would expect to see something more like

if (accountBeingTransferredFrom.equals(accountBeingTransferredInto)) {
   // can't transfer to same account

(but with your own variable names, obviously)

public void actionPerformed(ActionEvent e) {
        String cmd = e.getActionCommand();
        String id = passwordField.getText();  //gets "input" from text entry
        String transferaccount_id = atmData.getTransferaccount_id(id);
        String accountbalance = atmData.getAccountbalance(id);
        String accountBeingTransferredFrom = passwordField.getText();
        String accountBeingTransferredInto = passwordField.getText();
        if (CONTINUE.equals(cmd)) {
                char[] pwid = passwordField.getPassword();
                String intransferaccount_id =  new String (pwid);
                 
               
                if  (transferaccount_id.isEmpty()) {    // Account matches return from atmData.getid_inf
                JOptionPane.showMessageDialog(controllingFrame,
                "Invalid Number. Try again.",
                    "Error Message",
                    JOptionPane.ERROR_MESSAGE);
               
                }else if (intransferaccount_id.equals(transferaccount_id)){
                JOptionPane.showMessageDialog(controllingFrame,
                    "The account you have selected to transfer funds to is " + atmData.getTransferaccount_id (id));
                    atm.transferamountGUI();
                   

                    if (intransferaccount_id.equals(transferaccount_id)){
                String newBalance1 = atmData.getBalance();
                    for (int i = 0; i <= lines ; i++) {
                    newBalance1 = accountbalance;
                    lineTo = i;
                    break; 
                
                }
            
        }
        if (accountBeingTransferredFrom.equals(accountBeingTransferredInto))

                   JOptionPane.showMessageDialog(controllingFrame,
                "You cannot transfer money to yourself!. Try again.",
                    "Error Message",
                    JOptionPane.ERROR_MESSAGE);
             
            
            }
    }
}

Ok so i tried your advice, however it still is not working ='(

with your own variable names

you ignored that bit of my "advice".
Frankly, if you think you can just paste in some code that doesn't use your own variable names then maybe computer programming isn't the career for you.

Would it matter though? because i assigned the variables to those names...

But you set them both to be the contents of the password field!
I honestly don't know what's going on here. Maybe I'm not the right person to help with this. Just ignore me, I'm sure someone else will be better able to advise you. Sorry. J

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.