Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Jan 2011
    Thanked 0 Times in 0 Posts

    Problem with ImageIcon need help.

    Hi everyone,
    Im making a Memory game and i need to add images to the buttons. i also use a int so it will randomise it. but this is my problem:

    this will add the image and goes correct now i need to add the int with it:ImageIcon img = new ImageIcon(this.getClass().getResource("mountain.gif"));

    This wont work because i'm getting a nullPointerException:ImageIcon img = new ImageIcon(this.getClass().getResource("no[0]+mountain.gif"));

    Also if i do this:ImageIcon img = new ImageIcon(no[0]+ "" + this.getClass().getResource("mountain.gif"));

    then it works but it doesnt show the image

    How could i add the no[0] (int) to the image so it will randomise it?!
    Last edited by Proceeded; 01-23-2011 at 03:07 PM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts