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?
You can use UI.addWindow method:
...
MyWindow myWindow = new MyWindow();
UI.getCurrent().addWindow(myWindow);
...
Please, check out Vaadin Book chapter on subwindows.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.