Vaadin Window move to anther screen

Hello,

I would like to open a pdf file in a window and I would like this window can be move to another screen (the user can have two screen).
I try with this code :

Window window = new Window();
window.setWidth(“90%”);
window.setHeight(“90%”);
window.setResizable(true);
BrowserFrame e = new BrowserFrame(“PDF File”, new ExternalResource(“http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf”));
e.setWidth(“100%”);
e.setHeight(“100%”);
window.setContent(e);
UI.getCurrent().addWindow(window);

But the window is still attached to the current UI so I can’t move it.

I tried with BrowserWindowOpener. This open the document in a new browser window which can be move to the other screen.
But I don’t want to click to a button.

Is there a solution ?
Thanks a lot for your help
Bertrand

I currently use Vaadin 7.6.1

The Vaadin Window component is not a browser window, it is just a floating DIV element. To open something separate from your main app, you need to do it in another browser window. BrowserWindowOpener is the best way to do it, but there is another way that might work.

Page.getCurrent.open()

That method is deprecated though, from the JavaDoc:

* As of Vaadin 7.0.0, the functionality for opening a Resource in a Page * has been replaced with similar methods based on a String URL. This is * because the usage of Resource is problematic with memory management and * with security features in some browsers. Is is recommended to instead use * {@link Link} for starting downloads. Long story short, you can use open(), but it might not work correctly in all browsers because of security blocks. The security checks only allow opening windows as a direct response to a click, hence we made the BrowserWindowOpener (and the Link component does the same thing).

Thanks a lot, it works.

Hello Thomas,

I have another question concerning BrowserWindowOpener. Can we dynamically set resource when we click on the button ?
Indeed, as Page.getCurrent.open() is deprecated, I would like to use BrowserWindowOpener. But I would like to feed the resource after we clik on the button.

Thanks

You can try calling setResource in a clicklistener, but I doubt it will work (the window opener is triggered in the same event as the click listener, so setting the resource there might be too late).