Forums Register Login

NullPointer Exception error.

+Pie Number of slices to send: Send
I have an NPE error which starts at line 66, in the setImage() method. I will try my best to reduce as my code shown as possible.

File is GameFrame.java.

Basically, initialize() method calls setImage() method and subsequently, initialize() method is in the GameFrame constructor which is called by the GameFrame main method to be run.

Any help in solving the NPE error is appreciated.









Error code:
+Pie Number of slices to send: Send
A NullPointerException almost always happens because you're calling a method on a variable that is null.

In your code, it's most likely puzpiece that is null when line 66 executes. Find out why it is null there, and either add a check or fix the problem so that it's not null when line 66 is reached.
+Pie Number of slices to send: Send
 

Jesper de Jong wrote:A NullPointerException almost always happens because you're calling a method on a variable that is null.

In your code, it's most likely puzpiece that is null when line 66 executes. Find out why it is null there, and either add a check or fix the problem so that it's not null when line 66 is reached.



Yup, I solved the issue regarding the NPE.

But now I have a new error - java.lang.IllegalArgumentException: Width (0) and height (0) must be non-zero.

Does this mean that the image import via failed somehow?
Get out of my mind! Look! A tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 842 times.
Similar Threads
Serialization/Deserialization of an Array of Objects
Serialization/Deserialization a picture
NullPointerException with setting up an array of Rectangles
problem with JTextField null
problems creating a new larger array with one extra element
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 06:42:13.