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 :
theFrame.setLocationRelativeTo(null);
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.
Easy!
Saturday, April 26, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment