This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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

Win a copy of Building Microservices this week in the Design forum!
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.
I agree. Here's the link:
subject: window position
It's not a secret anymore!