File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes window position Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "window position" Watch "window position" New topic
Author

window position

chris barr
Ranch Hand

Joined: Apr 20, 2006
Posts: 37
when i create a new window i want it to appear in the center of the screen or at least not the upper left hand conner how do you set were it appears?
Martin Simons
Ranch Hand

Joined: Mar 02, 2006
Posts: 196
This is one of my favorite ways:
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
you could also try

frame.setLocationRelativeTo(null);

but must be called after the size of the frame is set
i.e. after setSize(...) or after pack()
chris barr
Ranch Hand

Joined: Apr 20, 2006
Posts: 37
thanks .. that works perfectly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: window position