I often get asked how to center a JFrame or JDialog on the desktop or another frame. It's really a quite simple operation. All you need is the following command :
This command will set the frame object as CENTERED on the main desktop of the current operating system. If you replace the null with the name of another object, like a parent frame in a JDialog window you can center the JDialog on a JFrame.