如何在 Vaadin 中显示模态 Window?

How to display a modal Window in Vaadin?

我是 Vaadin 的新手,仍在学习中。在这里,我试图编译一个基本的 Vaadin 项目。我想要它并在 UI 运行时显示模态 window,但我遇到了麻烦。这是我目前所拥有的:

CaptchaUI.java -

import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.UI;


public abstract class CaptchaUI extends UI {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @Override
    protected void init(VaadinRequest request) {
        addWindow(new CaptchaWindow());

    }
}

CaptchaWindow.java -

import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;


public class CaptchaWindow extends Window {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    public CaptchaWindow() {

    // Some other UI content
    setContent(new Label("Here's my UI"));

    // Create a sub-window and set the content
    Window subWindow = new Window("Sub Window");
    VerticalLayout subContent = new VerticalLayout();
    subContent.setMargin(true);
    subWindow.setContent(subContent);

    // Put some components in it
    subContent.addComponent(new Label("Label"));
    subContent.addComponent(new Button("Button"));

    // Center it in the browser window
    subWindow.center();

    // Open it in the UI
    addWindow(subWindow);

    }
}

有人可以给我一些帮助或建议来展示它吗?

非常感谢。

根据Vaadin docs设置就和设置一样简单

setModal(true)

在子 window 上使其成为模态。

请注意,Vaadin 的模式功能只是客户端限制。在浏览器中使用调试工具修改 HTML 仍然可以在后台单击按钮。