-2

I am doing a slot machine. I have 3 classes, Symbol,Reel, Gui. How do I display the images in to the Jlabels? I need to populate the ArrayList in the reel class and use the List in the Gui class to display images in the JLabels.

JohnDoe
  • 1
  • 2

1 Answers1

1
p3.setIcon(listImages.get(2).getIcon());
satnam
  • 10,719
  • 5
  • 32
  • 42
  • getting the exception now Exception in thread "main" java.lang.NullPointerException at javax.swing.ImageIcon.(ImageIcon.java:217) at framet.Reel.(Reel.java:17) at framet.Gui.(Gui.java:21) at framet.Gui.main(Gui.java:53) – JohnDoe Nov 23 '16 at 18:06
  • 1
    This is because java is having trouble finding the image. You need to make sure the images are located in the same folder as Reel.java – satnam Nov 23 '16 at 18:08
  • they are in the same folder the SRC folder, i have added the screen shot – JohnDoe Nov 23 '16 at 18:15
  • You can look at this for help on loading an image from your filesystem: http://stackoverflow.com/questions/16631636/what-is-the-correct-path-to-display-an-imageicon-png-file-for-windows-7 – satnam Nov 23 '16 at 18:18
  • Ok, finally see your screenshot. You are trying to load "seven.png" and the image is called "redseven.png" – satnam Nov 23 '16 at 18:24