Java项目,vaadin 7我很难找到一种方法来防止在单击内部按钮之前关闭窗口。我希望窗口也保持在其他屏幕内容的顶部。到目前为止我的代码:
private void handleButtonCancelBatches() {
if (projectBatchTeller > 0) {
Button btnYes = new Button("Yes");
Button btnNo = new Button("No");
// toDo add click listeners to the buttons
HorizontalLayout horizontalLayout = new HorizontalLayout();
horizontalLayout.addComponents(btnYes, btnNo);
// toDo add extra informative content to the horizontalLayout
Window window = new Window( //
"Cancel "+ projectBatchTeller + " selected batches ?", horizontalLayout);
window.setWidth(50f, Unit.PERCENTAGE);
window.setHeight(50f, Unit.PERCENTAGE);
window.setPosition((int) getUI().getWidth() / 2, (int) getUI().getHeight() / 2);
getUI().getCurrent().addWindow(window);
} else {
Notification.show("No batches selected to cancel");
}
}
// toDo add listeners / handlers for the buttons
我真正需要的是典型消息框中的行为,但是我不允许添加pom中的额外依赖项,也不能升级到Vaadin的较新版本。
如果不可能,我想在60秒后自动关闭窗口,发送Notifaction通知正在执行默认路径,女巫未处理批次
有什么建议吗?谢谢
我自己找到了一个可行的解决方案。实际上很简单,问题是我不知道“情态”一词(我说荷兰语)
此代码不会阻止关闭,但会产生类似于msgbox的行为(例如在C#中……)
window.setModal(true);