我创建的子窗口不会关闭。我看到有些人遇到了同样的问题并发布了相同的问题,但我仍然无法找到解决方案。我检查了this,and this,and this,and that,但未找到解决方案。这是'我的代码,用于窗口的相应类:
public class CommunicationConfigWindow extends Window
{
private static CommunicationConfigWindow INSTANCE;
private final Accordion catAccordion = new Accordion();
private final VerticalLayout layout = new VerticalLayout();
private final HorizontalLayout toolbar = new HorizontalLayout();
private final Button applyButton = new Button( "Save&Close" );
private final Button cancelButton = new Button( "Cancel" );
private CommunicationConfigWindow( )
{
this.toolbar.setDefaultComponentAlignment( Alignment.MIDDLE_CENTER );
this.applyButton.setSizeFull();
this.cancelButton.addClickListener( e -> {
UI.getCurrent().removeWindow( this );
this.close();
} );
this.applyButton.addStyleName( ValoTheme.BUTTON_FRIENDLY );
this.cancelButton.addStyleName( ValoTheme.BUTTON_DANGER );
this.cancelButton.setSizeFull();
this.toolbar.addComponents( this.cancelButton, this.applyButton );
this.toolbar.setSizeFull();
this.catAccordion.addTab( new GeneralCatLayer( CatVersionEnum.CAT21 ), "CAT 21" );
this.catAccordion.addTab( new GeneralCatLayer( CatVersionEnum.CAT23 ), "CAT 23" );
this.catAccordion.addTab( new GeneralCatLayer( CatVersionEnum.CAT247 ), "CAT 247" );
this.layout.addComponents( this.catAccordion, this.toolbar );
this.setContent( this.layout );
}
public static CommunicationConfigWindow getINSTANCE()
{
if ( CommunicationConfigWindow.INSTANCE == null )
{
CommunicationConfigWindow.INSTANCE = new CommunicationConfigWindow();
}
return CommunicationConfigWindow.INSTANCE;
}
}
This is before I click on cancel. This is after I click on cancel.
我会从window
弹出这个Display Settings Button
。会发生什么:
当我点击取消或关闭按钮时,我基本上希望窗口消失,但它根本没有。为什么?
提前致谢。
答案 0 :(得分:2)
你的单身人士可能有问题。你真的需要单身窗吗?
如果您只想在按钮上添加一个窗口,请单击。你可以尝试一些验证,如
Window yourWindow = new Window();
if (UI.getCurrent().getWindows().contains(yourWindow)) {
getUI().addWindow(yourWindow);
}
在窗口类中重写等于
答案 1 :(得分:0)
我没有改变任何东西,经过2个小时的花费,它开始工作,虽然我没有改变一件事,我不知道为什么。