|
|
|
|
Re: Centering a Dialog on Screen [message #465073 is a reply to message #465049] |
Mon, 05 December 2005 14:21 |
Eclipse User |
|
|
|
Originally posted by: kwpeck.mersoft.com
zinc wrote:
> Hi,
> How can I center a dialog or shell on screen? For example, I have a
> fixed size custom Dialog, how can I make it appear in the center of the
> screen?
>
> Thanks.
>
If you are doing this at startup and you don't have a "good" shell /
display (which I did not with my login dialog) then the following code
will center on the 1st monitor in a multiple monitor setup or only
monitor if you only have a single.
Monitor [] ma = display.getMonitors();
if (ma != null)
m_shell.setLocation((ma[0].getClientArea().width - pixel.width) /
2, (ma[0].getClientArea().height - pixel.height) / 2);
In this case I have the height / width of the dialog stored in the
"pixel" variable.
|
|
|
Powered by
FUDForum. Page generated in 0.03124 seconds