Problem with notifications after closing window

Hello, i have problem.

When i closing the Window i want to display notifications. My Window is in external class, which extends Window. I’m closing this window by close(); and my metod look like this



        no.addListener(new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                
                getWindow().showNotification("Porzucono operację", Window.Notification.TYPE_TRAY_NOTIFICATION);
                
                close();
            }
        });

Notifications are displayed when i open the window second time.

What’s wrong with it?
Greetings