Another way to handle that is to have your own local buffer image and draw on that first, then draw the image onto the graphics object passed in by the system.
code example:
/* These are your buffers */
Image buffer;
Graphics bufferGraphics;
public void paint(Graphics g)
{
Dimension d = getSize();
if (buffer == null)
{
buffer = createImage(d.width, d.height);
bufferGraphics = buffer.getGraphics();
}
bufferGraphics.drawLine(0, 0, 100, 100);
g.drawImage(buffer, 0, 0, this);
}
You can also use the bufferGraphics in other methods according to your needs.
Originally posted by Sergei Voropay:
I'm working on an applet derived from JApplet class. When running the applet in browser and scrolling the page in any direction, the applet flickers. Is there a way of getting rid of this annoying behavior?