I just fixed this in my code a few days ago.
public void render()
{
// If we’ve lost our video memory, don’t bother drawing anything
// This happens when resizing a window or deiconifying the application
if (!bufferStrategy.contentsLost())
{
Graphics2D g = (Graphics2D) bufferStrategy.getDrawGraphics();
fwm.screenManager.render(g);
bufferStrategy.show();
g.dispose();
}
else //Try to recover the buffer strategy contents
{
//System.out.println("bufferStrategy, contents lost!");
baseFrame.createBufferStrategy( 3 );
bufferStrategy = baseFrame.getBufferStrategy();
//System.out.println("recovered if false : "+bufferStrategy.contentsLost());
if(!bufferStrategy.contentsLost())
render();// we recovered so render stuff
}
}
If you resize a window larger or iconify/deiconify the app you will almost always lose the BufferStrategy.
Remove the comments on the print lines to see it happen. Its odd that in the sample I was looking at, it had the first if() statement to not draw if the contents were lost but it didnt have the recovery step 