[5971] in java-interest
Re: (no subject)
daemon@ATHENA.MIT.EDU (BrianX Maso)
Wed Mar 6 16:06:32 1996
Date: Wed, 06 Mar 96 11:47:00 PST
From: BrianX Maso <BrianX_Maso@ccm.jf.intel.com>
To: java-interest@java.sun.com
Text item:
>Hello,
>
>I have a couple of questions mostly dealing with centering Frames
>and Dialog Boxes.
>
>
>1. How do I center a Dialog Box within a Frame?
Follow these steps:
1. Get the placement and dimensions of the Frame:
Rectangle rectFrame = myFrame.bounds();
The x and y members of rectFrame is the upper-left corner of the Frame on
the screen. The width and height members, obviously, are the dimensions of the
Frame.
2. Get the dimensions of the Dialog:
Dimension dimDialog = myDialog.size();
3. Center the Dialog over the Frame:
dimDialog.move(rectFrame.x+(rectFrame.width/2) -(rectDialog.width/2),
rectFrame.y+(rectFrame.height/2)-(rectDialog.height/2));
>2. How do I center a Frame on the Screen?
The screen dimensions are available from the Toolkit:
Dimension dimDesktop = Toolkit.getDefaultToolkit().getScreenSize();
To center the Frame:
Dimension dimFrame = myFrame.size();
myFrame.move(dimDesktop.width/2 - dimFrame.width/2,
dimDesktop.height/2 - dimFrame.height/2);
> My screen dimensions are 1024 X 786. I even tried hardcoding
>frame.move(512,384).
The point (512, 384) indicates the upper-left corner of the Frame, which would
place the upper-left corner of the Frame at the center of the desktop, but won't
center the frame over the desktop. (See above)
Brian Maso
Text item: External Message Header
The following mail header is for administrative use
and may be ignored unless there are problems.
***IF THERE ARE PROBLEMS SAVE THESE HEADERS***.
X-Info: To unsubscribe, send 'unsubscribe' to java-interest-request@java.sun.com
Precedence: bulk
Sender: owner-java-interest@javasoft.com
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Subject: (no subject)
To: java-interest@java.sun.com
MIME-Version: 1.0
X-Mailer: Mozilla 1.1N (Windows; I; 16bit)
Organization: ESMPD
From: Raymond Davis <rdavis@Census.GOV>
Date: Tue, 05 Mar 96 17:14:24 -0500
Message-Id: <199603052212.RAA00721@info.census.gov>
Received: (from majordom@localhost) by java0.javasoft.com (8.6.12/8.6.12) id OAA
10382 for java-interest-outgoing; Tue, 5 Mar 1996 14:11:57 -0800
Received: (from daemon@localhost) by java0.javasoft.com (8.6.12/8.6.12) id OAA10
389 for java-interest-recipients; Tue, 5 Mar 1996 14:12:00 -0800
Received: from java0.javasoft.com (java.Sun.COM [206.26.48.100]) by ormail.intel
.com (8.7.4/8.7.3) with SMTP id TAA19214; Tue, 5 Mar 1996 19:31:32 -0800 (PST)
Received: from ormail.intel.com (ormail.intel.com [134.134.192.3]) by relay.jf.i
ntel.com (8.6.12/8.6.12) with ESMTP id TAA14865; Tue, 5 Mar 1996 19:31:38 -0800
Return-Path: daemon@javasoft.com
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com