Created
August 5, 2014 06:44
-
-
Save tiltedlistener/72c8d61fd199ca83921f to your computer and use it in GitHub Desktop.
Center a JFrame within a screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
From this post: http://stackoverflow.com/questions/2442599/how-to-set-jframe-to-appear-centered-regardless-of-the-monitor-resolution