Of course you're going to get a NullPointerException. You have declared a DebugGraphics REFERENCE variable called 'dgr'. At no point have you created a DebugGraphics OBJECT and assigned it to the reference.
What you want:
Code:
DebugGraphics dgr = new DebugGraphics();
dgr.drawString("Image",30,0);
dgr.drawString("not",30,30);
dgr.drawString("Found",30,60);
image.paintIcon(null,gr,0,0);
Stack trace: Highlight the text in the console using the mouse. Then right-click. The text is now in clipboard. Now past it into wherever you'd like.
The Problem: I came into this problem a little late, what are you actually trying to do? I've always obtained graphics contexts from controls, rather than creating new ones.
Bookmarks