How to center a JFrame on screen
I'm often asked, "How do I center a JFrame on screen?", or, "Is there a method to center a JFrame?"
I always center my initial JFrame on screen using the setLocationRelativeTo
method, and pass it a null
reference. As the Javadoc for setLocationRelativeTo
method states: