Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Kevin Jenkins   on Apr 21 In Java Category.

  
Question Answered By: Vicki Fields   on Apr 21

Use the Toolkit object to get the screen  size.

Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screen = kit.getScreenSize();
frame.setBounds(screen.width/4,screen.height/4, screen.width/2,
screen.height/2);

or use the frame.setLocation() method instead of setBounds()
frame.pack();
frame.setLocation((screen.width-frame.getWidth())/2, (screen.height-
frame.getHeight())/2);

Share: 

 
 
Didn't find what you were looking for? Find more on JFrame in the middle of the screen Or get search suggestion and latest updates.


Tagged: