Vaadin 8 Print Window and Close it After Print

Hello,

In Vaadin 8 I’m trying to create a new Window, print it, and close it automatically after it was printed.

I have found exactly what I want to do but with Vaadin 6 (does not work with Vaadin 8):

[code]
// Open it as a popup window with no decorations
getWindow().open(new ExternalResource(window.getURL()),
“_blank”, 500, 200, // Width and height
Window.BORDER_NONE); // No decorations

// Print automatically when the window opens.
// This call will block until the print dialog exits!
window.executeJavaScript(“print();”);

// Close the window automatically after printing
window.executeJavaScript(“self.close();”);
[/code]I have tried the following but the window is not closing after the page gets printed:

//Create window and add it to the UI window JavaScript.getCurrent().execute("print();"); JavaScript.getCurrent().execute("self.close();"); Any ideas? Should I start looking into creating a new thread?

Thanks!