Thanks a lot for your reply - I tried it with 1.3.1, 1.4.2, 1.5.0_u7 and mustang b93 and it happened everywhere except 1.3.1.
An interesting result is that this bug does not happen as soon as something is drawn in XOR mode.
I really guess its a bug in my drawing code, I must have broken something. All the VI handling is done through reflection since the code is 1.1 compatible, I attached the drawing code below, the class is not complete I just included whats really related to this topic.
It would be great if someone could give it a short look.
Thanks in advance, lg Clemens
import java.awt.*;
import java.lang.reflect.*;
public class LwPaintManImpl extends LwPaintManager
{
protected Dimension MAX_BUFFER_SIZE;
protected Image buffer;
protected boolean isBuffered;
static boolean isAccerlated = false;
static Class volatileClass;
static Method createVImage;
static Method getGraphicsConfiguration;
static Method volatileValidate;
static Method volatileContentsLost;
static Object[] emptyParaArray =
{};
static int IMAGE_INCOMPATIBLE;
static
{
try
{
Class[] createVIParams =
{ Integer.TYPE, Integer.TYPE };
Class[] emptyParams =
{};
Class[] validateParams =
{ Class.forName("java.awt.GraphicsConfiguration") };
volatileClass = Class.forName("java.awt.image.VolatileImage");
IMAGE_INCOMPATIBLE = volatileClass.getField("IMAGE_INCOMPATIBLE").getInt(null);
System.out.println(IMAGE_INCOMPATIBLE);
createVImage = java.awt.Component.class.getMethod("createVolatileImage", createVIParams);
getGraphicsConfiguration = java.awt.Component.class.getMethod("getGraphicsConfiguration", emptyParams);
volatileValidate = volatileClass.getMethod("validate", validateParams);
volatileContentsLost = volatileClass.getMethod("contentsLost", emptyParams);
isAccerlated = true;
System.out.println("Accerlated!");
} catch (Exception ex)
{
ex.printStackTrace();
isAccerlated = false;
}
}
protected/* C#override */void paintDesktop(Graphics g, LwDesktop d)
{
if (isAccerlated)
{
paintDesktopAccerlated(g, d);
} else
{
paintDesktopUnAccerlated(g, d);
}
}
protected void paintDesktopAccerlated(Graphics g, LwDesktop d)
{
try
{
int w = d.getWidth(), h = d.getHeight();
if (isBuffered && w <= MAX_BUFFER_SIZE.width && h <= MAX_BUFFER_SIZE.height)
{
Component nat = (Component) d.getNCanvas();
Object gconf = getGraphicsConfiguration.invoke(nat, emptyParaArray);
if (buffer == null || w > buffer.getWidth(null) || h > buffer.getHeight(null))
{
Integer[] createVIParams =
{ new Integer(w), new Integer(h) };
buffer = (Image) createVImage.invoke(nat, createVIParams);
}
synchronized (LOCKER)
{
Rectangle da = g.getClipBounds();
Graphics gg = null;
try
{
do
{
Object[] validateParams =
{ gconf };
int valCode = ((Integer) volatileValidate.invoke(buffer, validateParams)).intValue();
if (valCode == IMAGE_INCOMPATIBLE)
{
Integer[] createVIParams =
{ new Integer(w), new Integer(h) };
buffer = (Image) createVImage.invoke(nat, createVIParams);
}
int xx = da.x + da.width, yy = da.y + da.height;
if (LwToolkit.desktops > 1 || d.getDA().width >= 0)
{
gg = buffer.getGraphics();
gg.clearRect(da.x, da.y, da.width, da.height);
gg.setClip(da.x, da.y, da.width, da.height);
super.paintDesktop(gg, d);
}
g.drawImage(buffer, da.x, da.y, xx, yy, da.x, da.y, xx, yy, null);
} while (((Boolean) volatileContentsLost.invoke(buffer, emptyParaArray)).booleanValue());
} finally
{
if (gg != null)
gg.dispose();
}
}
} else
super.paintDesktop(g, d);
} catch (Exception ex)
{
ex.printStackTrace();
}
}
}