Vaadin 8, no modal window?

Hello,

I’m just trying to build a modal window. I learnt it from this tutorial:
https://examples.javacodegeeks.com/enterprise-java/vaadin/vaadin-window-example/
It looks amazing nice and it works if I import this project to my local workspace.

But if I try to integrate it into my previous project I get pretty weird behaviour… It shows me that methon:

addWindow(modalWindow); is undefined

Could somebody help me please?

My code:

    @PostConstruct
    public void init() {

 
        
        Button bModalWindow = new Button("Modal Window");
        bModalWindow.addClickListener(new Button.ClickListener() {
                public void buttonClick(ClickEvent event) {
                        ModalWindow modalWindow = new ModalWindow();
                        addWindow(modalWindow);

                }
        });
        addComponent(bModalWindow);
        
        Window myWindow = new Window("My Window");
        VerticalLayout windowContent = new VerticalLayout();
        windowContent.setMargin(true);
        myWindow.setContent(windowContent);
        myWindow.setWidth("250px");
        windowContent.addComponent(new Label("This is a window"));
        myWindow.center();
        myWindow.addStyleName("mywindowstyle");
        addWindow(myWindow);

    }

I’m not sure but is really your “ModalWindow” class extending “Window” class from “com.vaadin.ui.Window”?
This could help:
https://vaadin.com/docs/-/part/framework/layout/layout-sub-window.html

Hi,

The method addWindow is a method of the UI class. Is your snippet part of a class that extends UI?