Adds additional handling for when BufferStrategy contents are restored/lost.
@@ -82,6 +82,9 @@ public class Panel extends Canvas implements Receiver<String> {
/** Draws every character of every row onto the canvas. */
public void draw() {
final BufferStrategy bs = this.getBufferStrategy();
+
+ do {
+ do {
final Graphics2D gc;
try {
@@ -111,7 +114,10 @@ public class Panel extends Canvas implements Receiver<String> {
screen.draw(gc, imageCache);
gc.dispose();
+ } while (bs.contentsRestored()); // Repeat render if drawing buffer contents were restored.
+
bs.show();
+ } while (bs.contentsLost()); // Repeat render if drawing buffer was lost.
}
/**
