Window modal mode, problems with images

Hi, i’m having problems with displaying an image in a modal window. I need to specify either the height or the width of a window and dynamically set the other virtice. But i don’t know the image’s width/height parameters, because there is no way to get that from com.smartgwt.client.widgets.Img. Is there?

public Window createImageWindow (String id){
	Window window = new Window();  
	window.setAutoSize(true);  
	window.setTitle("Image");  
	window.setWidth(400);  
	window.setHeight(400);  
	window.setCanDragReposition(true);  
	window.setCanDragResize(true);
	window.setIsModal(true);
	window.centerInPage();  
	Img img = new Img("/spaceoptions/imageServe.do?id="+id+"&thumbnail=false");  
		
	img.setImageType(ImageStyle.NORMAL);  
	img.setWidth(400); 		 
	System.out.println("img width: " + img.getWidth());
	System.out.println("img height: " + img.getHeightAsString());
	Layout canvas = new  Layout();
	canvas.setTop(20);
	canvas.setWidth100();
	canvas.setHeight100();
	canvas.addChild(img);
	window.addChild(canvas); 
	return window;
}

Hi, ysbelman.
If you just want to make the window fit the image (autoresizing to the image natural size), then remove all the width/height setters in your example code.