It's not a secret anymore!*
The moose likes Swing / AWT / SWT and the fly likes The dialog won't be centered? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "The dialog won Watch "The dialog won New topic
Author

The dialog won't be centered?

Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 590

It goes to a little bit right hand side of the screen
Any ideas?
Tanks
Jack
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

While steLocationRelativeTo(null) is the corrrect and accepted way to center a window on the screen, the posted code shouldn't result in a window that
goes to a little bit right hand side of the screen


Either initComponents() is changing the width of the dialog or the monitor isn't correctly calibrated.


luck, db
There are no new questions, but there may be new answers.
Jacky Luk
Ranch Hand

Joined: Aug 02, 2012
Posts: 590
Darryl Burke wrote:While steLocationRelativeTo(null) is the corrrect and accepted way to center a window on the screen, the posted code shouldn't result in a window that
goes to a little bit right hand side of the screen


Either initComponents() is changing the width of the dialog or the monitor isn't correctly calibrated.


Hi Darryl,
I found the bug, it was because the initComponents() should be called before setLocation
Thanks
Jack
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The dialog won't be centered?
 
Similar Threads
Closing parent and child with ESC
How modal is too modal?
How is modality implemented?
Modal Dilag box
How to open a separate new window