Skip to content

Instantly share code, notes, and snippets.

@devwolf75
Created March 8, 2019 18:52
Show Gist options
  • Save devwolf75/97f529f5d0aaf5aaacae155cc5626022 to your computer and use it in GitHub Desktop.
Save devwolf75/97f529f5d0aaf5aaacae155cc5626022 to your computer and use it in GitHub Desktop.
JFrame example.
import javax.swing.JFrame;
import javax.swing.JPanel;
class Main {
private static final String TITLE = "My Game";
private static final int[] DIMENSIONS = {800, 600};
public static void main(String s[]) {
JFrame frame = new JFrame(TITLE);
JPanel panel = new JPanel();
panel.setLayout(null);
frame.add(panel);
frame.setSize(DIMENSIONS[0], DIMENSIONS[1]);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment