如何在vaadin中关闭窗口? [英] How to close window in vaadin?
问题描述
我有类 MyCustomWindow,它从 vaadin 扩展了 Window (com.vaadin.ui).当您单击某个按钮时,MyCustomWindow 将显示.现在我想向这个窗口添加按钮,当你按下这个按钮时,它会关闭窗口.我有问题要使用什么来删除此窗口.我发现:
I have got class MyCustomWindow which extends Window (com.vaadin.ui) from vaadin. When you click some button MyCustomWindow will show. Now I would like to add button to this window and when you push this buton it will close the window. I have got problem what to use to remove this window. I have found:
Window w = getWindow();
getApplication().removeWindow(w);
或
Window w = this.findAncestor(Window.class);
w.close();
但它不起作用.我想使用this"从班级内部而不是外部移除窗口?类似的东西:
But it doesn't work. I would like to remove window from inside the class, not from outside, using "this"? Something like:
UI.getCurrent().removeWindow(this);
我正在使用 vaadin 7.你能帮我吗?
I am using vaadin 7. Can you help me?
推荐答案
您好,如果您想从单击侦听器内部关闭窗口,您可以执行以下两项操作之一:
Hello if you want to close the window from inside your click listener you can do one of the following two things:
yourButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
MyCustomWindow.this.close();
}
});
或者:
yourButton.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
closeMyCustomWindow();
}
});
private void closeMyCustomWindow(){
this.close();
}
closeMyCustomWindow() 这个函数在 MyCustomWindow 类中.
closeMyCustomWindow() this function is inside the MyCustomWindow class.
这篇关于如何在vaadin中关闭窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!