cadmy
cadmy

Reputation: 535

How could I know if the window is opened or not in Vaadin?

I use one layout in few cases. But when I show this layout in the window (com.vaadin.ui.Window) I have to hide one button otherwise layout stays unchanged. So I would like to know is the window opened or not at the moment. Is the any way to figure that out?

Upvotes: 0

Views: 580

Answers (2)

Krayo
Krayo

Reputation: 2510

I don't fully understand your question, but maybe this helps:

public class MyLayout extends VerticalLayout {

    private Button myButton; // set it in the constructor

    @Override
    public void setParent(HasComponents parent) {
        super.setParent(parent);
        myButton.setVisible(!(parent instanceof Window)); // or recursively if need
    }

}

Upvotes: 0

cfrick
cfrick

Reputation: 37008

with getWindows you get all the windows of an UI. and with isAttached you will find out, if it is attached to the session (in a state where the user should see it)

Upvotes: 2

Related Questions