Skip to content

Instantly share code, notes, and snippets.

@tiltedlistener
Created August 5, 2014 06:44
Show Gist options
  • Save tiltedlistener/72c8d61fd199ca83921f to your computer and use it in GitHub Desktop.
Save tiltedlistener/72c8d61fd199ca83921f to your computer and use it in GitHub Desktop.
Center a JFrame within a screen
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment