File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes NullPointer in Image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "NullPointer in Image" Watch "NullPointer in Image" New topic

NullPointer in Image

vivek ja
Ranch Hand

Joined: Feb 24, 2005
Posts: 80
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

Joined: Feb 24, 2005
Posts: 80
the Graphics.isHeadLess() is returning false, still I am getting null.
This is very urgent, pls help
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
What is your createImage() method really doing?

:alex |.::the_mindstorm::.

blog -
vivek ja
Ranch Hand

Joined: Feb 24, 2005
Posts: 80
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!
I agree. Here's the link:
subject: NullPointer in Image
Similar Threads
Unknown number of rows to create a JTable
i got a problem, with my test program on binary trees
reading returned datas from the url
null pointer
Numeric Null Comparison