• Post Reply Bookmark Topic Watch Topic
  • New Topic

NullPointerException when using repaint() method  RSS feed

 
Dario Stroob
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i'm trying to make a little game in java. I use a MouseMotionListener to determine the mouseposition. There is a picture that should follow the mouse in my JFrame, so I recall the paint-class everytime the mouse moves. However I always get a NullPointerException when i use the method .repaint() in the Listener class. Any ideas how i can fix this?
thanks a lot




 
dennis deems
Ranch Hand
Posts: 808
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Window field "wind" in MoorhuhnMain is never assigned. The run method creates a JFrame named "wind", but this is a local variable. It is never assigned to the instance variable.
 
Dario Stroob
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh man i'm sorry this was a very stupid mistake... -.-'
thanks a lot anyways
 
dennis deems
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a mistake we've all made at one point or another.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch (from somebody else who had done that!)
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!