J2ME Image / Graphics my misunderstanding?

Hi,

I have a mutable Image which I am using as an offscreen buffer. I initialise this image by setting the colour to white and calling the fillRect() method with the screen size as parameters. I do this in the constructor for my Canvas object.

In my paint() method I then draw only the extra things on the backbuffer (since I have already filled the image with white) and use the drawImage() method of the screens Graphics object to copy the backBuffer onto the screen of my device.

The problem is that text from the previous Form shows up, as if I have not filled the backBuffer with a white rectangle....

Code :

Initialisation :

backBuffer = Image.createImage(screenWidth,screenHeight);

Graphics g = backBuffer.getGraphics();

g.setColor( 255, 255, 255 );

g.fillRect( 0, 0, getWidth(), getHeight() );

In my paint() method :

Graphics saved = g; // Save the frame buffer

g = backBuffer.getGraphics();

g.setColor(255,0,0); // change the colour to red

// Draw the selection box.

g.drawRect(x,y,imageWidth,imageHeight);

saved.drawImage(backBuffer,0,0,Graphics.LEFT|Graphics.TOP);

Thanks,

Norris

[1212 byte] By [norrissmith] at [2007-9-27 14:35:39]
# 1
cross post http://forums.java.sun.com/thread.jsp?forum=4&thread=284543
Abuse at 2007-7-5 22:35:05 > top of Java-index,Other Topics,Java Game Development...
# 2
Yep sorry didn't know which forum to put it in.Thanks for the link.
norrissmith at 2007-7-5 22:35:05 > top of Java-index,Other Topics,Java Game Development...