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 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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP 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: 601

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: 4642
    
    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: 601
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?