Skip to content

Instantly share code, notes, and snippets.

@alifa98
Created May 24, 2019 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alifa98/58b5da7f7213b656df99cfbdbec17577 to your computer and use it in GitHub Desktop.
Save alifa98/58b5da7f7213b656df99cfbdbec17577 to your computer and use it in GitHub Desktop.
How to center a Jframe in swing
jframe.setLocationRelativeTo(null); //this should be done after setting the size or calling pack(), but before setting it visible, like this:
/*
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment