Skip to content

Instantly share code, notes, and snippets.

Created August 18, 2012 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/3389137 to your computer and use it in GitHub Desktop.
Save anonymous/3389137 to your computer and use it in GitHub Desktop.
Screen Tearing - GameWindow.java
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();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment