List of usage examples for com.vaadin.ui PasswordField PasswordField
public PasswordField(ValueChangeListener<String> valueChangeListener)
From source file:ch.bfh.ti.soed.hs16.srs.white.view.RegistrationView.java
License:Open Source License
public RegistrationView(AbstractView lastView) { super(lastView); fieldFirstName = new TextField("First Name"); fieldLastName = new TextField("Last Name"); fieldEmail = new TextField("E-Mail Address"); fieldConfirmEmail = new TextField("Repeat E-Mail Address"); fieldPassword = new PasswordField("Password"); fieldConfirmPassword = new PasswordField("Repeat Password"); btnSubmit = new Button("Submit"); btnCancel = new Button("Cancel"); labelMessage = new Label(); loadController();// www.ja v a 2s . co m }
From source file:com.cavisson.gui.dashboard.components.controls.TextFields.java
License:Apache License
public TextFields() { setMargin(true);/*from www.j ava 2 s . c o m*/ Label h1 = new Label("Text Fields"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); TextField tf = new TextField("Normal"); tf.setInputPrompt("First name"); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField("Custom color"); tf.setInputPrompt("Email"); tf.addStyleName("color1"); row.addComponent(tf); tf = new TextField("User Color"); tf.setInputPrompt("Gender"); tf.addStyleName("color2"); row.addComponent(tf); tf = new TextField("Themed"); tf.setInputPrompt("Age"); tf.addStyleName("color3"); row.addComponent(tf); tf = new TextField("Error"); tf.setValue("Somethings wrong"); tf.setComponentError(new UserError("Fix it, now!")); row.addComponent(tf); tf = new TextField("Error, borderless"); tf.setValue("Somethings wrong"); tf.setComponentError(new UserError("Fix it, now!")); tf.addStyleName("borderless"); row.addComponent(tf); tf = new TextField("Read-only"); tf.setInputPrompt("Nationality"); tf.setValue("Finnish"); tf.setReadOnly(true); row.addComponent(tf); tf = new TextField("Small"); tf.setValue("Field value"); tf.addStyleName("small"); row.addComponent(tf); tf = new TextField("Large"); tf.setValue("Field value"); tf.addStyleName("large"); tf.setIcon(testIcon.get(true)); row.addComponent(tf); tf = new TextField("Icon inside"); tf.setInputPrompt("Ooh, an icon"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField("Large, Icon inside"); tf.setInputPrompt("Ooh, an icon"); tf.addStyleName("large"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField("Small, Icon inside"); tf.setInputPrompt("Ooh, an icon"); tf.addStyleName("small"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField("16px supported by default"); tf.setInputPrompt("Image icon"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get(true, 16)); row.addComponent(tf); tf = new TextField(); tf.setValue("Font, no caption"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField(); tf.setValue("Image, no caption"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get(true, 16)); row.addComponent(tf); CssLayout group = new CssLayout(); group.addStyleName("v-component-group"); row.addComponent(group); tf = new TextField(); tf.setInputPrompt("Grouped with a button"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get()); tf.setWidth("260px"); group.addComponent(tf); Button button = new Button("Do It"); // button.addStyleName("primary"); group.addComponent(button); tf = new TextField("Borderless"); tf.setInputPrompt("Write here"); tf.addStyleName("inline-icon"); tf.addStyleName("borderless"); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField("Right-aligned"); tf.setValue("1,234"); tf.addStyleName("align-right"); row.addComponent(tf); tf = new TextField("Centered"); tf.setInputPrompt("Guess what?"); tf.addStyleName("align-center"); row.addComponent(tf); PasswordField pwf = new PasswordField("Password"); pwf.setInputPrompt("Secret words"); pwf.addStyleName("inline-icon"); pwf.setIcon(FontAwesome.LOCK); row.addComponent(pwf); pwf = new PasswordField("Password, right-aligned"); pwf.setInputPrompt("Secret words"); pwf.addStyleName("inline-icon"); pwf.addStyleName("align-right"); pwf.setIcon(FontAwesome.LOCK); row.addComponent(pwf); pwf = new PasswordField("Password, centered"); pwf.setInputPrompt("Secret words"); pwf.addStyleName("inline-icon"); pwf.addStyleName("align-center"); pwf.setIcon(FontAwesome.LOCK); row.addComponent(pwf); tf = new TextField("Tiny"); tf.setValue("Field value"); tf.addStyleName("tiny"); row.addComponent(tf); tf = new TextField("Huge"); tf.setValue("Field value"); tf.addStyleName("huge"); row.addComponent(tf); h1 = new Label("Text Areas"); h1.addStyleName("h1"); addComponent(h1); row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); TextArea ta = new TextArea("Normal"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); ta = new TextArea("Inline icon"); ta.setInputPrompt("Inline icon not really working"); ta.addStyleName("inline-icon"); ta.setIcon(testIcon.get()); row.addComponent(ta); ta = new TextArea("Custom color"); ta.addStyleName("color1"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); ta = new TextArea("Custom color, read-only"); ta.addStyleName("color2"); ta.setValue("Field value, spanning multiple lines of text"); ta.setReadOnly(true); row.addComponent(ta); ta = new TextArea("Custom color"); ta.addStyleName("color3"); ta.setValue("Field value, spanning multiple lines of text"); row.addComponent(ta); ta = new TextArea("Small"); ta.addStyleName("small"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); ta = new TextArea("Large"); ta.addStyleName("large"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); ta = new TextArea("Borderless"); ta.addStyleName("borderless"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); ta = new TextArea("Right-aligned"); ta.addStyleName("align-right"); ta.setValue("Field value, spanning multiple lines of text"); row.addComponent(ta); ta = new TextArea("Centered"); ta.addStyleName("align-center"); ta.setValue("Field value, spanning multiple lines of text"); row.addComponent(ta); ta = new TextArea("Tiny"); ta.addStyleName("tiny"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); ta = new TextArea("Huge"); ta.addStyleName("huge"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); RichTextArea rta = new RichTextArea(); rta.setValue("<b>Some</b> <i>rich</i> content"); row.addComponent(rta); rta = new RichTextArea("Read-only"); rta.setValue("<b>Some</b> <i>rich</i> content"); rta.setReadOnly(true); row.addComponent(rta); }
From source file:com.cerebro.provevaadin.database.Configurazione.java
public Configurazione() { System.out.println("Componente per la personalizzazione"); this.setMargin(true); TextField db_host = new TextField("Database Host Name"); db_host.isRequired();/* www . j a v a2s . c om*/ TextField db_port = new TextField("Database Port"); db_port.isRequired(); TextField db_user = new TextField("Username"); db_user.isRequired(); PasswordField db_pwd = new PasswordField("Password"); db_pwd.isRequired(); PasswordField pwd_conf = new PasswordField("Conferma Password"); pwd_conf.setImmediate(true); Properties props = new Properties(); InputStream config = VaadinServlet.getCurrent().getServletContext() .getResourceAsStream("/WEB-INF/config.properties"); if (config != null) { System.out.println("Carico file di configurazione"); try { props.load(config); } catch (IOException ex) { Logger.getLogger(MySQLServer.class.getName()).log(Level.SEVERE, null, ex); } } db_host.setValue(props.getProperty("db_host")); db_user.setValue(props.getProperty("db_user")); Button salva = new Button("Salva"); salva.addClickListener((Button.ClickEvent event) -> { System.out.println("Salvo i parametri"); if (db_host.isValid() && db_port.isValid() && db_user.isValid() && db_pwd.isValid() && pwd_conf.getValue().equals(db_pwd.getValue())) { String dbHost = "jdbc:mysql://" + db_host.getValue() + ":" + db_port.getValue() + "/grizzly?useSSL=false&serverTimezone=UTC"; props.setProperty("db_host", dbHost); props.setProperty("db_user", db_user.getValue()); props.setProperty("db_pwd", db_pwd.getValue()); String webInfPath = VaadinServlet.getCurrent().getServletConfig().getServletContext() .getRealPath("WEB-INF"); File f = new File(webInfPath + "/config.properties"); try { OutputStream o = new FileOutputStream(f); try { props.store(o, "Prova"); } catch (IOException ex) { Logger.getLogger(Configurazione.class.getName()).log(Level.SEVERE, null, ex); } } catch (FileNotFoundException ex) { Logger.getLogger(Configurazione.class.getName()).log(Level.SEVERE, null, ex); } Notification.show("Parametri salvati"); } else { Notification.show("Ricontrolla i parametri"); } }); Button test = new Button("Test per i parametri salvati"); test.addClickListener((Button.ClickEvent event) -> { System.out.println("Testo i parametri"); MySQLServer mysql = new MySQLServer(); JDBCConnectionPool conn = mysql.getJDBCConnPool(); if (!mysql.testJDBCConnPool(conn)) { Notification.show("Errore nella connessione al database"); } else { Notification.show("Connessione avvenuta con successo"); } }); this.addComponents(db_host, db_port, db_user, db_pwd, pwd_conf, salva, test); }
From source file:com.cerebro.provevaadin.smtp.ConfigurazioneSMTPSpring.java
public ConfigurazioneSMTPSpring() { TextField smtpHost = new TextField("SMTP Host Server"); smtpHost.setRequired(true);/*from ww w . j a v a 2s . c om*/ TextField smtpPort = new TextField("SMTP Port"); smtpPort.setRequired(true); TextField smtpUser = new TextField("SMTP Username"); smtpUser.setRequired(true); PasswordField smtpPwd = new PasswordField("SMTP Password"); smtpPwd.setRequired(true); PasswordField pwdConf = new PasswordField("Conferma la Password"); pwdConf.setRequired(true); CheckBox security = new CheckBox("Sicurezza del server"); Properties props = new Properties(); InputStream config = VaadinServlet.getCurrent().getServletContext() .getResourceAsStream("/WEB-INF/config.properties"); if (config != null) { System.out.println("Carico file di configurazione"); try { props.load(config); } catch (IOException ex) { Logger.getLogger(ConfigurazioneSMTP.class.getName()).log(Level.SEVERE, null, ex); } } smtpHost.setValue(props.getProperty("mail.smtp.host")); smtpUser.setValue(props.getProperty("smtp_user")); security.setValue(Boolean.parseBoolean(props.getProperty("smtp_sec"))); Button salva = new Button("Salva i parametri"); salva.addClickListener((Button.ClickEvent event) -> { System.out.println("Salvo i parametri SMTP"); if (smtpHost.isValid() && smtpPort.isValid() && smtpUser.isValid() && smtpPwd.isValid() && smtpPwd.getValue().equals(pwdConf.getValue())) { System.out.println(smtpHost.getValue() + smtpPort.getValue() + smtpUser.getValue() + smtpPwd.getValue() + security.getValue().toString()); props.setProperty("mail.smtp.host", smtpHost.getValue()); props.setProperty("mail.smtp.port", smtpPort.getValue()); props.setProperty("smtp_user", smtpUser.getValue()); props.setProperty("smtp_pwd", smtpPwd.getValue()); props.setProperty("mail.smtp.ssl.enable", security.getValue().toString()); String webInfPath = VaadinServlet.getCurrent().getServletConfig().getServletContext() .getRealPath("WEB-INF"); File f = new File(webInfPath + "/config.properties"); try { OutputStream o = new FileOutputStream(f); try { props.store(o, "Prova"); } catch (IOException ex) { Logger.getLogger(ConfigurazioneSMTP.class.getName()).log(Level.SEVERE, null, ex); } } catch (FileNotFoundException ex) { Logger.getLogger(ConfigurazioneSMTP.class.getName()).log(Level.SEVERE, null, ex); } Notification.show("Parametri salvati"); } else { Notification.show("Ricontrolla i parametri"); } }); TextField emailTest = new TextField("Destinatario Mail di Prova"); emailTest.setImmediate(true); emailTest.addValidator(new EmailValidator("Mail non valida")); Button test = new Button("Invia una mail di prova"); test.addClickListener((Button.ClickEvent event) -> { System.out.println("Invio della mail di prova"); if (emailTest.isValid() && !emailTest.isEmpty()) { System.out.println("Invio mail di prova a " + emailTest.getValue()); JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); mailSender.setJavaMailProperties(props); mailSender.setUsername(props.getProperty("smtp_user")); mailSender.setPassword(props.getProperty("smtp_pwd")); MimeMessage message = mailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message); try { helper.setFrom("dottmatteocasagrande@gmail.com"); helper.setSubject("Subject"); helper.setText("It works!"); helper.addTo(emailTest.getValue()); mailSender.send(message); } catch (MessagingException ex) { Logger.getLogger(ConfigurazioneSMTPSpring.class.getName()).log(Level.SEVERE, null, ex); } } else { Notification.show("Controlla l'indirizzo mail del destinatario"); } }); this.addComponents(smtpHost, smtpPort, smtpUser, smtpPwd, pwdConf, security, salva, emailTest, test); }
From source file:com.digitallabs.demos.Vaadin6BootstrapThemeDemo.java
License:Apache License
private void forms(ComponentContainer container) { VerticalLayout form = new VerticalLayout(); form.addStyleName(Bootstrap.Forms.FORM.styleName()); form.setSpacing(true);/*w ww . j a v a 2 s .c om*/ form.setCaption("Legend"); TextField email = new TextField("Email address"); email.setInputPrompt("Enter email"); form.addComponent(email); PasswordField password = new PasswordField("Password"); password.setInputPrompt("Password"); form.addComponent(password); Upload upload = new Upload("File input", null); form.addComponent(upload); Label help = new Label("Example block-level help text here."); help.addStyleName("help-block"); form.addComponent(help); CheckBox check = new CheckBox("Check me out"); form.addComponent(check); Button submit = new Button("Submit"); submit.addStyleName(Bootstrap.Buttons.DEFAULT.styleName()); form.addComponent(submit); container.addComponent(form); }
From source file:com.ejt.vaadin.loginform.LoginForm.java
License:Apache License
/** * Customize the password field. Only for overriding, do not call. * @return the password field//from w ww . jav a 2s. c om */ protected PasswordField createPasswordField() { checkInitialized(); return new PasswordField(getPasswordFieldCaption()); }
From source file:com.github.djabry.platform.vaadin.view.LoginView.java
License:Open Source License
private Component buildFields() { HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true);// w w w . ja va 2 s . c o m userField = new TextField("Username"); userField.setIcon(FontAwesome.USER); userField.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); //username.addStyleName(ValoTheme.TEXTFIELD_TINY); passwordField = new PasswordField("Password"); passwordField.setIcon(FontAwesome.LOCK); passwordField.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); //password.addStyleName(ValoTheme.TEXTFIELD_TINY); final Button signin = new Button("Sign In"); signin.addStyleName(ValoTheme.BUTTON_PRIMARY); signin.setClickShortcut(ShortcutAction.KeyCode.ENTER); //signin.addStyleName(ValoTheme.BUTTON_TINY); signin.focus(); fields.addComponents(userField, passwordField, signin); fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT); signin.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { loginAction.login(userField.getValue(), passwordField.getValue()); } }); return fields; }
From source file:com.gmail.volodymyrdotsenko.cms.fe.vaadin.LoginUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { langRepo.findAll().forEach(e -> { langSet.add(e.getCode());//from w w w .j av a 2s .c om }); lang = new ComboBox("Language", langSet); getPage().setTitle("CMS"); FormLayout loginForm = new FormLayout(); loginForm.setSizeUndefined(); loginForm.addComponent(userName = new TextField("Username")); userName.setRequired(true); loginForm.addComponent(passwordField = new PasswordField("Password")); passwordField.setRequired(true); loginForm.addComponent(rememberMe = new CheckBox("Remember me")); loginForm.addComponent(lang); lang.setRequired(true); lang.setNullSelectionAllowed(false); loginForm.addComponent(login = new Button("Login")); login.addStyleName(ValoTheme.BUTTON_PRIMARY); login.setDisableOnClick(true); login.setClickShortcut(ShortcutAction.KeyCode.ENTER); login.addClickListener(e -> { login(); }); VerticalLayout loginLayout = new VerticalLayout(); loginLayout.setSpacing(true); loginLayout.setSizeUndefined(); if (request.getParameter("logout") != null) { loggedOutLabel = new Label("You have been logged out!"); loggedOutLabel.addStyleName(ValoTheme.LABEL_SUCCESS); loggedOutLabel.setSizeUndefined(); loginLayout.addComponent(loggedOutLabel); loginLayout.setComponentAlignment(loggedOutLabel, Alignment.BOTTOM_CENTER); } loginLayout.addComponent(loginFailedLabel = new Label()); loginLayout.setComponentAlignment(loginFailedLabel, Alignment.BOTTOM_CENTER); loginFailedLabel.setSizeUndefined(); loginFailedLabel.addStyleName(ValoTheme.LABEL_FAILURE); loginFailedLabel.setVisible(false); loginLayout.addComponent(loginForm); loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER); VerticalLayout rootLayout = new VerticalLayout(loginLayout); rootLayout.setSizeFull(); rootLayout.setComponentAlignment(loginLayout, Alignment.MIDDLE_CENTER); setContent(rootLayout); setSizeFull(); String currentLang = getLocale().getLanguage(); if (langSet.contains(currentLang)) lang.select(currentLang); else lang.select("en"); }
From source file:com.jain.common.authenticate.LoginAction.java
License:Apache License
private void createFieldGroup(VerticalLayout layout) { I18NProvider provider = DefaultI18NResourceProvider.instance(); userName = new TextField("user.name"); userName.setCursorPosition(0);// w w w . j a v a 2 s . c o m userName.setRequired(true); userName.setRequiredError(provider.getMessage(getLocale(), "common.something.required", "user.name.title", JAction.LOGIN.getDisplayName())); userName.setDescription("user.name"); userName.setSizeFull(); userName.setStyleName(JNStyleConstants.J_FIELD); password = new PasswordField("password"); password.setRequired(true); password.setRequiredError(provider.getMessage(getLocale(), "common.something.required", "password.title", JAction.LOGIN.getDisplayName())); password.setDescription("password"); password.setSizeFull(); password.setStyleName(JNStyleConstants.J_FIELD); VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setStyleName(ApplicationTheme.VIEW); verticalLayout.setSpacing(true); verticalLayout.setMargin(true); verticalLayout.setWidth("100%"); FormLayout formLayout = new FormLayout(); formLayout.setStyleName(ApplicationTheme.ALTERNATE_VIEW); formLayout.setSpacing(true); formLayout.setMargin(true); formLayout.setWidth("100%"); formLayout.addComponent(userName); formLayout.addComponent(password); verticalLayout.addComponent(formLayout); layout.addComponent(verticalLayout); }
From source file:com.logicbomb.newschool.MyAppWidgetSet.LoginWidget.java
public LoginWidget() { setMargin(true);//w ww. j a va2 s. c o m setSpacing(true); Panel iPanel = new Panel(); iPanel.addStyleName("backColorWhite"); iPanel.setSizeUndefined(); addComponent(iPanel); TextField iTextField = new TextField("Username"); iTextField.setWidth("300px"); iTextField.setRequired(true); iTextField.setInputPrompt("Your username (eg. joe@email.com)"); iTextField.setIcon(FontAwesome.USER); iTextField.addValidator(new EmailValidator("Username must be an email address")); iTextField.setInvalidAllowed(true); iTextField.focus(); PasswordField iPasswordField = new PasswordField("Password"); iPasswordField.setIcon(FontAwesome.KEY); iPasswordField.setWidth("300px"); iPasswordField.setRequired(true); iPasswordField.setValue(""); iPasswordField.setNullRepresentation(""); Button iButton = new Button("Login"); iButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { addComponent(new Label("Login Successfully")); } }); FormLayout iFormLayout = new FormLayout(); iFormLayout.setSpacing(true); iFormLayout.setMargin(true); iFormLayout.addComponent(iTextField); iFormLayout.addComponent(iPasswordField); iFormLayout.addComponent(iButton); iPanel.setContent(iFormLayout); }