Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
01-23-2011, 03:01 PM #1
- Join Date
- Jan 2011
- Thanked 0 Times in 0 Posts
Problem with ImageIcon need help.
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+mountain.gif"));
Also if i do this:ImageIcon img = new ImageIcon(no+ "" + this.getClass().getResource("mountain.gif"));
then it works but it doesnt show the image
How could i add the no (int) to the image so it will randomise it?!
Last edited by Proceeded; 01-23-2011 at 03:07 PM.