Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Thomas Evans   on Apr 07 In Java Category.

  
Question Answered By: Oliver Evans   on Apr 07

maybe myToolkit.getImage is returning a null,to make sure, type this:
System.out.println("ruler="+ruler);
but dont write ruler.toString(), cos if ruler is null, then its like
typing :
null.toString()

and then passing null (ruler) to g.drawImage(null),,,,,,, will throw
an exception!

so the solution is , put
if(ruler==null)
{
//doAlternativeActionOrPicture();
}
else
{ Graphics g = jPanel2.getGraphics();
g.drawImage(ruler, 0, 0, jPanel2);
}

Share: 

 
 
Didn't find what you were looking for? Find more on What's wrong with this code Or get search suggestion and latest updates.


Tagged: