User-agent: Mozilla Thunderbird 1.0.7 (Windows/20050923)
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.