How to center a JFrame when it comes up

C

clusardi2k

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,
 
M

markspace

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!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top