Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   How to center a JFrame when it comes up (http://www.velocityreviews.com/forums/t951507-how-to-center-a-jframe-when-it-comes-up.html)

clusardi2k@aol.com 08-28-2012 10:03 PM

How to center a JFrame when it comes up
 
I would like to have a JFrame come up from anther one and center it on the screen. Hoe do I do this.

Can I do it with two JFrames produced in NetBeans Design view.

Thank you,

markspace 08-28-2012 11:57 PM

Re: How to center a JFrame when it comes up
 
On 8/28/2012 3:03 PM, clusardi2k@aol.com wrote:
> I would like to have a JFrame come up from anther one and center it
> on the screen. Hoe do I do this.
>
> Can I do it with two JFrames produced in NetBeans Design view.



This is an RTFM question, but the answer can be tricky to find, so:

<http://docs.oracle.com/javase/tutorial/uiswing/components/frame.html>


"This example does not set the frame location, but it is easy to do so
using either the setLocationRelativeTo or setLocation method. For
example, the following code centers a frame onscreen:

frame.setLocationRelativeTo(null);"


Read the docs!!




All times are GMT. The time now is 11:27 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.