Reputation: 4460
I have a window in my vaadin project and now I want to open another window over that.
I'm trying this.
public class MyWindow extends Window {
/** this is a window that I want open */
public MyWindow() {
super("MyWindow");
center();
VerticalLayout vLayout = new VerticalLayout();
vLayout.addComponent(new Label("MyWindow is opened");
setContent(vLayout);
}
}
public class OpenMyWindow extends Window {
/** this is a window that should open MyWindow */
private Button btnOpenMyWindow;
public OpenMyWindow() {
super("OpenMyWindow");
center();
VerticalLayout vLayout = new VerticalLayout();
btnOpenMyWindow = new Button("Open My Window");
btnOpenMyWindow.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
new MyWindow().setVisible(true);
}
});
vLayout.addComponent(btnOpenMyWindow);
setContent(vLayout);
}
}
How to do this?
Upvotes: 0
Views: 114
Reputation: 13426
You can use UI.addWindow method:
...
MyWindow myWindow = new MyWindow();
UI.getCurrent().addWindow(myWindow);
...
Please, check out Vaadin Book chapter on subwindows.
Upvotes: 2