Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The dialog won't be centered?

 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It goes to a little bit right hand side of the screen
Any ideas?
Tanks
Jack
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic