gpt4 book ai didi

java - 打开一个窗口与另一个窗口?

转载 作者:行者123 更新时间:2023-12-02 06:28:58 25 4
gpt4 key购买 nike

我的 vaadin 项目中有一个窗口,现在我想在其上打开另一个窗口。

我正在尝试这个。

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);
}
}

如何做到这一点?

最佳答案

您可以使用UI.addWindow方法:

...
MyWindow myWindow = new MyWindow();
UI.getCurrent().addWindow(myWindow);
...

请查看Vaadin Book chapter on subwindows.

关于java - 打开一个窗口与另一个窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20240020/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com