File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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


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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: window position