Problem displaying large image in application-level window

Hi,

I’d very much appreciate assistance with the following problem. As part of an application, I have list of thumbnail images, and clicking on one loads the full-size image corresponding to the thumbnail in a new browser window. This works fine, as long as the full-size image is smaller than the display. If the image is larger than the display, it is not displayed properly.

If I try to open a large image with a browser (just using “Open File”), the browser window resizes to just fill the display, and the image is resized to just fill the browser window. Also, the mouse cursor changes to a “+” symbol, to indicate that clicking will enlarge the image to its full size, with scrollbars as necessary added to the browser window. This is what I want to happen when the full-size image is opened in a new browser window from within the Vaadin app. What happens instead is that the browser window is resized to fill the display (which is fine), but the image is displayed at full resolution rather than sized to just fill the window, and I only get a vertical scrollbar, rather than both vertical and horizontal scrollbars (which are both necessary). This happens with both FireFox and Safari. With FireFox, if I right-click on the incorrectly displayed image and select the “View Image” menu item, it will then be displayed correctly; and in Safari, if I right-click on the incorrectly displayed image and select “Load image in new tab”, it will be loaded in a new tab, this time correctly. Obviously, the user can’t be expected to do these things. I haven’t tested with IE.

I’d really appreciate some help with this one – thanks very much in advance. I’ve included some of the relevant code below.

Matthew Fleming

String fileName = (String)((Embedded)event.getComponent()).getData();
File file = new File(Virtual_Followup_Application.fullDir, fileName);
Dimension dim = getImageDim(file.getPath());
FileResource rsrc = new FileResource(file, getApplication());
Embedded emb = new Embedded(null, rsrc);
final Window window = new Window();
window.addComponent(emb);
window.setName(fileName);
getApplication().addWindow(window);
getApplication().getMainWindow().open(new ExternalResource(window.getURL()) ,“_blank”,
dim.width, dim.height+30, Window.BORDER_DEFAULT);