• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting placement of JDialog

 
Jessica Dancel
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a modal JDialog that I pop up from a parent window. Right now it's appearing in the upper left corner of the screen. I'd like it to pop up centered over the parent window, but I can't find any methods to do this. Anyone know how?
Thanks in advance.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
specify the parent when you construct the dialog
 
Jessica Dancel
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, here's my code:



Anyone have a thought as to how to get myDialog centered over the instance of PanelClass? Thanks.

Jessica Dancel
[ January 03, 2007: Message edited by: Jessica Dancel ]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Brian Cole
Author
Ranch Hand
Posts: 907
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jessica Dancel:
myDialog = new DialogClass(new Frame());


I'm guessing that the DialogClass constructor passes the parameter to the superconstructor.

If so, then you want to pass in the actual parent frame so the dialog's position can be taken from it, not a newly constructed Frame object with which nothing else is done.
 
Jessica Dancel
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, guys. This gave me what I needed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic