A simple way to center a JFrame (Java JFrame)

This is a simple way to center a JFrame in Java:

myFrame.setLocationRelativeTo(null);

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.