GUIDE: how to center a JFace dialog [message #458706] |
Tue, 19 July 2005 17:35 |
Eclipse User |
|
|
|
Originally posted by: eclipse.vnws.com
Just overloading initializeBounds() method in your class, like this:
protected void initializeBounds()
{
super.initializeBounds();
Shell shell = this.getShell();
Monitor primary = shell.getMonitor();
Rectangle bounds = primary.getBounds ();
Rectangle rect = shell.getBounds ();
int x = bounds.x + (bounds.width - rect.width) / 2;
int y = bounds.y + (bounds.height - rect.height) / 2;
shell.setLocation (x, y);
}
hope it can help :)
|
|
|
|
Re: GUIDE: how to center a JFace dialog [message #458723 is a reply to message #458710] |
Wed, 20 July 2005 04:06 |
Eclipse User |
|
|
|
Originally posted by: eclipse.vnws.com
Konstantin Scheglov:
It seems better :) thank you !
Konstantin Scheglov wrote:
> Tan Nhu:
>
> JFace Window already does something like this in:
>
> protected Point getInitialLocation(Point initialSize)
>
> In any case, if you want change location, it is better override this
> method, not initializeBounds().
>
>> Just overloading initializeBounds() method in your class, like this:
>>
>> protected void initializeBounds()
>> {
>> super.initializeBounds();
>> Shell shell = this.getShell();
>> Monitor primary = shell.getMonitor();
>> Rectangle bounds = primary.getBounds ();
>> Rectangle rect = shell.getBounds ();
>> int x = bounds.x + (bounds.width - rect.width) / 2;
>> int y = bounds.y + (bounds.height - rect.height) / 2;
>> shell.setLocation (x, y);
>> }
>>
>> hope it can help :)
|
|
|
Powered by
FUDForum. Page generated in 0.02837 seconds