• Post Reply Bookmark Topic Watch Topic
  • New Topic

window alignment

 
Jithesh Kozhipurath
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai friends,
How can align a frame window to the center of screen. It should be there at the center in all the resolutions.
 
Fernando Sanz
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using JDK 1.3 or JDK 1.4?
 
Jithesh Kozhipurath
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for ur reply,
I am using jdk 1.4.
 
Fernando Sanz
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With JDK 1.4 you can use dialog.setLocationRelativeTo(null)
the "null" will make a dialog to appear on the center of the screen
If you're using JDK 1.3 you'd have to use something like:
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setLocation((int)(screenSize.getWidth()/2 - getSize().getWidth()/2),(int)(screenSize.getHeight()/2 - getSize().getHeight()/2));
 
Jithesh Kozhipurath
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai,
but my requirement is to size the frame to exactly fit int screen. it i user the toolkit and if i maximize the window the controls also becomes bigger
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!