Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

java- ActionListener not working

  • 24-04-2009 01: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, Registered Users 2 Posts: 2,297 ✭✭✭Ri_Nollaig


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


  • Registered Users, Registered Users 2 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