Sub-Window with Eclipse Visual Editor for Vaadin

As the Title suggests, I’d like to implement a sub-window in the “Layout” class which extends “Customcomponent” and which I am editing using the eclipse visual editor.

Using the code isn’t possible, as the error occurs:

A Window can only be added to a UI using UI.addWindow(Window window)

But When I initialize the subwindow in the ‘superior’ class extending UI, I can’t set it’s visibility with buttons from the “Layout” class. Or am I doing sth. wrong?

EDIT: A possible solution is to not access the sub-window from the “Layout” class directly, but call a method form the UI class which again itself accesses the sub-window (setVisible(true)… etc.).
…still, I’m not able to call addWindow(subWindow) within a method other than the init(Vaadinrequest request) method…

Is it correct that the opposite of subWindow.close() would be layout.addWindow(subWindow) ?