Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

java- ActionListener not working

Options
  • 24-04-2009 1:42pm
    #1
    Closed Accounts Posts: 2


    Hi,

    im trying to flick through images using back and next buttons using an action listener the next button works fine but by back button won't

    heres the code: http://www.pastebin.ca/1401863

    if any one could help that would be great
    Thanks


Comments

  • Registered Users Posts: 2,297 ✭✭✭Ri_Nollaig


    should be
    if(e.getSource().equals(next)) {
    
    } else if (e.getSource().equals(back)) {
    
    }
    


  • Registered Users Posts: 2,297 ✭✭✭Ri_Nollaig


    just in case you didnt know or dont understand why you should use equals() . "==" compares what the variable is actually pointing to. So for primative types like int,doubles,boolean == is grand as they point to their values but for object types it would be pointing to their references rather then their content.
    Its an easy mistake to make as its still valid code.


  • Closed Accounts Posts: 2 moopylala


    thanks for that, i didnt actually know that, i changed the code it didnt seem to fix the problem.
    i called the repaint method in start and that seems to have done the trick


Advertisement