Login component within a sub window

When the login is in sub-window , it doesn’t get into the Login event click.
My log shows it’s refresh the page once when clicking Login , but only the first click.

When the login is not in sub-window , it works.

	public Login(){
		LoginForm login = new LoginForm();
		login.setUsernameCaption("Email");
		login.addListener(new LoginForm.LoginListener() {
			public void onLogin(LoginEvent event) {
                                        ....
				}
				else
                                        ....
				
			}
		});
		addComponent(login);
	}

final MenuBar.MenuItem login = rightBar.addItem("Sign In", signInCommand);


			signInCommand = new Command() {
				public void menuSelected(MenuItem selectedItem) {
					if (signInSubWindow.getParent() != null) {
						// window is already showing
					} else {
						// Open the subwindow by adding it to the parent window
						getWindow().addWindow(signInSubWindow);
					}
			}};

		signInSubWindow = new Window ("Sign In");
		VerticalLayout layoutB = (VerticalLayout) signInSubWindow.getContent();
		layoutB.setMargin(true);
		layoutB.setSpacing(true);
		layoutB.setSizeUndefined();
		signInSubWindow.addComponent( login );
		signInSubWindow.center();
		signInSubWindow.setResizable(false);


Update :signInSubWindow.addComponent( new LoginForm() );
doesn’t work

Thanks in advance

You seem to add the menuitem that should open the subwindow to the subwindow, not an instance of Login. Replacing the signInSubWindow.addComponent( login ); with signInSubWindow.addComponent( new Login() ); should be a good place to start.

(This is with the assumption that the constructor is in fact separate from the other parts of code, and that Login extends some Component.)