• Post Reply Bookmark Topic Watch Topic
  • New Topic

NullPointerException

 
P. Sagdeo
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Thanks for all your help in previous post, but now I'm really stumped on what to do. There seems to be a runtime error like so:

And here's my code:

and by the way, the line of error is where I say getContentPane().add...
Thanks again
[ May 01, 2004: Message edited by: P. Sagdeo ]
[ May 01, 2004: Message edited by: P. Sagdeo ]
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In line 26 you declared a SettingFrame variable sframe in class scope

and then, without initializing it, ie, its value is null, tried to get its content pane in line 58

sframe has been declared but not instantiated > NullPointerException.
[ May 01, 2004: Message edited by: Craig Wood ]
 
P. Sagdeo
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In init don't I say:?
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you did. I beg your pardon.
 
P. Sagdeo
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pardon granted, but anyone know why this is happening?
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll try again. You instantiated a class

and used the instance variable (sframe) inside the class, doesn't work.

I rearranged some things and used some background colors to show the panels in the JApplet content pane. It compiles and runs now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!