Create a SubWindow in a View

I use vaadin 8.
I have the following class, in which i want to create a SubWindow:

@CDIView("TitleView")
public class TitleView extends VerticalLayout implements View {
	private Button details;

	public TitleView(TitleService service) {
		Button details = new Button("details");
		details.addClickListener(event -> showDetails());

		HorizontalLayout tb = new HorizontalLayout(details);
		addComponent(tb);
	}

	private void showDetails() {
        // Create a sub-window and set the content
        Window subWindow = new Window("Sub-window");
        VerticalLayout subContent = new VerticalLayout();
        subWindow.setContent(subContent);

        // Put some components in it
        subContent.addComponent(new Label("Meatball sub"));
        subContent.addComponent(new Button("Awlright"));

        // Center it in the browser window
        subWindow.center();

        // Open it in the UI, but not work
        addWindow(subWindow);
		=> Error !!!!!!!!!!!!!!!!!!!!!!!
	}

How can i add the Window to the View?

In Vaadin you cannot add Window into view. Windows are always added via UI. In your case this means that you need to change
addWindow(subWindow); → getUI().addWindow(subWindow);

Thanks
Now it works

Hi, any idea on how it needs to be done in Vaadin 14. Tried this getUI().get().add(windowScreen);
But this doesn’t work.