Java Vaadin子窗口不关闭
我创建的子窗口未关闭。我见过一些人经历过同样的问题,并且发布了同样的问题,但我仍然找不到解决办法。我已检查,,,但找不到解决方案。下面是窗口对应类的我的代码:Java Vaadin子窗口不关闭,java,vaadin,vaadin8,Java,Vaadin,Vaadin8,我创建的子窗口未关闭。我见过一些人经历过同样的问题,并且发布了同样的问题,但我仍然找不到解决办法。我已检查,,,但找不到解决方案。下面是窗口对应类的我的代码: public class CommunicationConfigWindow extends Window { private static CommunicationConfigWindow INSTANCE; private final Accordion catAccordion = new Accordion(
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;
}
}
我确实从显示设置按钮
弹出此窗口
。结果是:
提前谢谢。可能是您的单身问题。你真的需要单件窗口吗 如果只想在按钮上添加一个窗口,请单击。您可以尝试一些验证,如
Window yourWindow = new Window();
if (UI.getCurrent().getWindows().contains(yourWindow)) {
getUI().addWindow(yourWindow);
}
重写窗口类中的等于可能是singleton的问题。你真的需要单件窗口吗 如果只想在按钮上添加一个窗口,请单击。您可以尝试一些验证,如
Window yourWindow = new Window();
if (UI.getCurrent().getWindows().contains(yourWindow)) {
getUI().addWindow(yourWindow);
}
覆盖窗口类中的equals我没有更改任何内容,在花了2个小时之后,它开始工作,即使我没有更改任何内容,我也不知道为什么 我没有改变任何东西,在花了两个小时在这上面之后,它开始工作了,尽管我没有改变任何东西,我也不知道为什么 不是关于单身汉的。我很生气,甚至上了主课,但结果还是一样的。谢谢你提供的这些信息,如果我真的能够关闭窗口,我也会使用它。使用对象来添加窗口,而不是使用静态或单例对象。单例是一个非常糟糕的主意。即使应用程序只有一个用户,他们也可以在窗口打开时关闭浏览器,然后在上一个会话中singleton窗口仍然打开时启动新会话。@AdrianCox确实如此。谢谢你的建议。不是关于单身汉的。我很生气,甚至上了主课,但结果还是一样的。谢谢你提供的这些信息,如果我真的能够关闭窗口,我也会使用它。使用对象来添加窗口,而不是使用静态或单例对象。单例是一个非常糟糕的主意。即使应用程序只有一个用户,他们也可以在窗口打开时关闭浏览器,然后在上一个会话中singleton窗口仍然打开时启动新会话。@AdrianCox确实如此。谢谢你的建议。