Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #18371

Re: How to center a JFrame when it comes up

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From markspace <-@.>
Newsgroups comp.lang.java.programmer
Subject Re: How to center a JFrame when it comes up
Date Tue, 28 Aug 2012 16:57:12 -0700
Organization A noiseless patient Spider
Lines 22
Message-ID <k1jlss$qj5$1@dont-email.me> (permalink)
References <0704555b-cf8b-4319-9949-b39cb098991c@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Tue, 28 Aug 2012 23:57:16 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="104ea93b2a90d763b2b4538d1ef3ad00"; logging-data="27237"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ENBl3/6fPjV+4LXOvTKoNthHqc/o36xc="
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0
In-Reply-To <0704555b-cf8b-4319-9949-b39cb098991c@googlegroups.com>
Cancel-Lock sha1:MxyeSqjx6NVYU2fn92KNMos3xd0=
Xref csiph.com comp.lang.java.programmer:18371

Show key headers only | View raw


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

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

How to center a JFrame when it comes up clusardi2k@aol.com - 2012-08-28 15:03 -0700
  Re: How to center a JFrame when it comes up markspace <-@.> - 2012-08-28 16:57 -0700

csiph-web