How do I create and Image for double buffering for an application and get the Graphics for it to not be null? I know how to double buffer in a applet so I dont know why this doesnt work. the class extends Canvas and I do something like this to make it create an Image and Graphics :
Dimension d; Image offImage; Graphics2D g2;
public DrawArea() { d = getSize(); offImage = createImage(d.width, d.height); g2 = (Graphics2D) offImage.getGraphics(); }
but when ever it runs, it throws a null pointer exception in the init of the main, and this class, like the JFrame is trying to add it but the DrawArea class throws a null pointer exception. Please Help!!