This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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


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: 631

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: 4986
    
    8

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: 631
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
 
Have you checked out Aspose?
 
subject: The dialog won't be centered?
 
It's not a secret anymore!