Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsGUIDE: how to center a JFace dialog
https://www.eclipse.org/forums/index.php/mv/msg/145734/458706/#msg_458706
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 :)]]>2005-07-19T17:35:15-00:00Re: GUIDE: how to center a JFace dialog
https://www.eclipse.org/forums/index.php/mv/msg/145734/458710/#msg_458710
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 :)]]>Konstantin Scheglov2005-07-19T19:00:36-00:00Re: GUIDE: how to center a JFace dialog
https://www.eclipse.org/forums/index.php/mv/msg/145734/458723/#msg_458723
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 :)]]>2005-07-20T04:06:12-00:00