public
anonymous / GameWindow.java
Created

Screen Tearing - GameWindow.java

  • Download Gist
GameWindow.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
import java.awt.Dimension;
 
import javax.swing.JFrame;
import javax.swing.JScrollPane;
 
public class GameWindow extends JFrame {
 
private JScrollPane viewer;
private GameCanvas canvas;
public static final Dimension SIZE = new Dimension(800, 600);
public GameWindow() {
super();
canvas = new GameCanvas();
viewer = new JScrollPane(canvas);
viewer.setPreferredSize(SIZE);
viewer.remove(viewer.getHorizontalScrollBar());
viewer.remove(viewer.getVerticalScrollBar());
viewer.setWheelScrollingEnabled(false);
getContentPane().add(viewer);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
setResizable(false);
setPreferredSize(SIZE);
setVisible(true);
canvas.initBufferStrat();
}
 
public void render() {
canvas.render();
}
 
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.