public void validate(Graphics2D g)
    {
        GraphicsConfiguration config = g.getDeviceConfiguration();
        do
        {
            if (vi == null)
            {
                vi = config.createCompatibleVolatileImage(bi.getWidth(), bi.getHeight(), quality);
                drawToVolatileImage(config);
            }
            else
            {
                int code = vi.validate(config);
                if (code == VolatileImage.IMAGE_RESTORED)
                {
                    drawToVolatileImage(config);
                }
                else if (code == VolatileImage.IMAGE_INCOMPATIBLE)
                {
                    vi = config.createCompatibleVolatileImage(bi.getWidth(), bi.getHeight(),
                            quality);
                    drawToVolatileImage(config);
                }
            }
        } while (vi.contentsLost());
    }