Moves creation of the BufferStrategy outside of the draw function.
@@ -25,6 +25,8 @@ public class Panel extends Canvas implements Receiver<String> {
@Getter private Radio<String> radio = new Radio<>();
+ final BufferStrategy bufferStrategy = this.getBufferStrategy();
+
/**
* Constructs a new VTerminal.
*
@@ -56,7 +58,6 @@ public class Panel extends Canvas implements Receiver<String> {
/** Draws every character of every row onto the canvas. */
public void draw() {
- final BufferStrategy bufferStrategy = this.getBufferStrategy();
final Graphics2D gc = (Graphics2D) bufferStrategy.getDrawGraphics();
gc.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
@@ -75,9 +76,9 @@ public class Panel extends Canvas implements Receiver<String> {
gc.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED);
currentScreen.draw(gc, asciiFont);
+ gc.dispose();
bufferStrategy.show();
- gc.dispose();
}
/**
