public LoginDialog(ApplicationContext context, LoginListener loginListener) { super("Login to Metl"); this.context = context; this.loginListener = loginListener; settings = new TypedProperties(); settings.putAll(context.getOperationsSerivce().findGlobalSettingsAsMap()); passwordExpiresInDays = settings.getInt(GlobalSetting.PASSWORD_EXPIRE_DAYS, 60); setWidth(300, Unit.PIXELS); setResizable(false); setModal(true); setClosable(false); LoginForm loginForm = new LoginForm() { @Override protected Component createContent(TextField userNameField, PasswordField passwordField, Button loginButton) { VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); LoginDialog.this.userNameField = userNameField; userNameField.setWidth(100, Unit.PERCENTAGE); LoginDialog.this.passwordField = passwordField; passwordField.setWidth(100, Unit.PERCENTAGE); passwordField.setNullRepresentation(""); layout.addComponent(userNameField); layout.addComponent(passwordField); validatePasswordField = new PasswordField("Verify Password"); validatePasswordField.setWidth(100, Unit.PERCENTAGE); validatePasswordField.setNullRepresentation(""); validatePasswordField.setVisible(false); layout.addComponent(validatePasswordField); HorizontalLayout buttonLayout = new HorizontalLayout(); loginButton.setStyleName(ValoTheme.BUTTON_PRIMARY); LoginDialog.this.loginButton = loginButton; buttonLayout.addComponent(loginButton); buttonLayout.setWidth(100, Unit.PERCENTAGE); layout.addComponent(buttonLayout); buttonLayout.addComponent(loginButton); buttonLayout.setComponentAlignment(loginButton, Alignment.BOTTOM_RIGHT); userNameField.focus(); return layout; } }; loginForm.addLoginListener((e) -> login()); loginForm.setWidth(300, Unit.PIXELS); setContent(loginForm); }