• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

:P NullPointerException madness..

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
err i get a kinda big NullPointerException when i run this and i can't fix this! any ideas? (code for the program is below)

 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the code doesn't help much, because it won't compile as is -- probably because I don't have the chn.util package.

When you get the exception, it should tell you the line number that caused the problem. Please tell us where the problem is, and we can probably help you.
 
Kyle Berry
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well... heres a pic with all the errors in it with the lines...

http://img54.imageshack.us/img54/9128/runescape00007xf.jpg
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in createAccountForm
accountContent.add(msg, BorderLayout.CENTER);
msg could be null

msg is created in createBattlePanel(), but I don't know
which method is called first
 
Kyle Berry
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Michael Dunn:
in createAccountForm
accountContent.add(msg, BorderLayout.CENTER);
msg could be null

msg is created in createBattlePanel(), but I don't know
which method is called first



oh two msgs... whoops lol x_X'' smart of me... and createBattlePanel() isn't called yet...
 
Kyle Berry
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
great now my program lags my comp like crazy for some reason when it tries to load my loginToGame method..
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
from loginToGame()
while(accountName == null)
{
accountName = ui.grabAccountName();
}

then from grabAccountName()
if(accountName != null) //<---check value of accountName
...
else return null;

could be that grabAccountName is returning null, causing infinite loop
in the while() of loginToGame
 
Kyle Berry
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Michael Dunn:
from loginToGame()
while(accountName == null)
{
accountName = ui.grabAccountName();
}

then from grabAccountName()
if(accountName != null) //<---check value of accountName
...
else return null;

could be that grabAccountName is returning null, causing infinite loop
in the while() of loginToGame



thanks... ill try a different way of doing this later...
reply
    Bookmark Topic Watch Topic
  • New Topic