Skip to content

Instantly share code, notes, and snippets.

@kleinlennart
Last active May 24, 2018 11:18
Show Gist options
  • Save kleinlennart/5adbfd5e604f3ade628ad2ec275b1895 to your computer and use it in GitHub Desktop.
Save kleinlennart/5adbfd5e604f3ade628ad2ec275b1895 to your computer and use it in GitHub Desktop.
Template - Default Initializer for JFrame
public static final int WIDTH = 1280;
public static final int HEIGHT = 720;
private void initialize() {
frame = new JFrame();
frame.setTitle("title");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
frame.setPreferredSize(new Dimension(WIDTH, HEIGHT));
frame.setMaximumSize(new Dimension(WIDTH, HEIGHT));
frame.setMinimumSize(new Dimension(WIDTH, HEIGHT));
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setFocusable(true);
}
//Proper call of setVisiible
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
TestWindow window = new TestWindow();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment