Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Null Pointer Exception  RSS feed

 
Martin vanPutten
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a nullpointerexception runtime error I can't figure out why. I have two classes... one with the print method... and the other thatpulls that method into a textarea... does anybody see any problem with this:


For further reference... heres the entire two classes:

 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Martin vanPutten
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't I have to call the Game class in order to get the printWelcome method?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, but nowhere in ViewPanel do you create an instance of 'Game'.

you probably want to pass a reference to the game object you create in main(),
via ViewPanel's constructor
 
Martin vanPutten
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't believe I forgot to do that... its always the little things! Thanks!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!