Skip to content
Advertisement

Creating a new window on button click – Vaadin14

I want to create a new Window using:

final Window window = new Window("Window");
this.getUI().addWindow(window);

This is from the Vaadin homepage https://demo.vaadin.com/sampler/#ui/structure/window

But unfortunately my IDE is showing the following error: The constructor Window(String) is undefined.

When i delete the string, it says: the constructor Window() is not visible.

Why is that? In the vaadin demo it works just fine.

Advertisement

Answer

There is no Window class in Vaadin 14.

The demo page you linked in the question is about Vaadin 8.

In Vaadin Flow (Vaadin 10+), the Dialog is used instead of the old Window. It’s not exactly the same as the old Window – for example the Dialog has no maximize or close button automatically. But along with other components you want to show within that Dialog, you can add for example a button that will close the dialog when clicked. Or let the dialog close when the user clicks outside it using dialog.closeOnOutsideClick(true);

Edit: go check out this vaadin blog post of a good looking Dialog example, with video (and code is also linked there): https://vaadin.com/blog/new-component-features-and-development-time-improvements-in-vaadin-14

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement