i keep getting this:
Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(ImageIcon.java:205)
at Pinopoly.diceRoll.<init>(diceRoll.java:17)
at Pinopoly.board.<init>(board.java:26)
at Pinopoly.board.main(board.java:38)
Java Result: 1

i used:
dice1.setIcon(new ImageIcon(getClass().getResource("/new/dice1.jpg")));
the image is in the same folder as the java files.

what could be wrong?

oh and i tried changing the image and it worked.

If the image is in the same folder as Java file, the "/new/dice1.jpg" should be only "dice1.jpg"? Because the getResource() couldn't find the file, it returns an NPE. Also, be sure that the file name is case sensitive - exact case.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.