Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NullPointer in Image

 
vivek ja
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the follwoing lines of code and am getting a NullPointerException
in the second line because i is null.
How will i call createImage so that i will have some value.

java.awt.Image i=this.createImage(800,1000);
Graphics g= i.getGraphics(); //null pointer here

I am new to swing and now just started writing code for this class.
Please help!
 
vivek ja
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the Graphics.isHeadLess() is returning false, still I am getting null.
This is very urgent, pls help
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is your createImage() method really doing?

--
:alex |.::the_mindstorm::.
 
vivek ja
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am in the process of testing something, and I need a graphics object to input as parameter in a method.
So to create that i have

java.awt.Image i=createImage(800,1000);
Graphics g= i.getGraphics();

Thank you!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic