Name: rlT66838 Date: 07/23/97 calling createImage(int,int) of the Component class always returns null instead of the requested image ====================================================================== In the following code, the call to createImage returns NULL and the next line of code raises a java.lang.NullPointerException. This happens on Solaris and NT 4.0. Please look at the constructor for ScribbleCanvas. class ScribbleCanvas extends Canvas { Image drawImg; Graphics drawGr; int xprev, yprev; public void paint(Graphics g) { g.drawImage(drawImg, 0, 0, null); } public ScribbleCanvas() { drawImg = createImage(100,100); drawGr = drawImg.getGraphics(); setBackground(Color.gray); setSize(300,300); } public boolean mouseDown(Event evt, int x, int y) { xprev = x; yprev = y; return true; } public boolean mouseDrag(Event evt, int x, int y) { drawGr.drawLine(xprev, yprev, x, y); xprev = x; yprev = y; repaint(); return true; } } joon.oh@Eng 1997-09-29
|