[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform.swt] GUIDE: how to center a JFace dialog

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 :)