Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make a Frame appear at the center

Status
Not open for further replies.

aryajur

Programmer
Jul 2, 2003
45
US
Hello, I need to know how can one create a frame and display it exactly at teh centre of the current windows screen. If I try to get the dimensions by getMaximumSize() it returns a huge value for the height and width something like 32767. So I cannot get the screen simensions. How should I do this.

 
Dimension size = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation( ( size.width-frame.getWidth() )/2,( size.height-frame.getHeight() )/2 );
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top