针对JPasswordField可以替代吗?和javajpasswordfield这两个问题,本篇文章进行了详细的解答,同时本文还将给你拓展.newPasswordforSecureField选择强密
针对JPasswordField可以替代吗?和java jpasswordfield这两个问题,本篇文章进行了详细的解答,同时本文还将给你拓展.newPassword for SecureField 选择强密码在使用 SwiftUI 和 iOS14 时不起作用、AFGPasswordTextField、com.intellij.ui.components.JBPasswordField的实例源码、com.vaadin.ui.PasswordField的实例源码等相关知识,希望可以帮助到你。
本文目录一览:- JPasswordField可以替代吗?(java jpasswordfield)
- .newPassword for SecureField 选择强密码在使用 SwiftUI 和 iOS14 时不起作用
- AFGPasswordTextField
- com.intellij.ui.components.JBPasswordField的实例源码
- com.vaadin.ui.PasswordField的实例源码
JPasswordField可以替代吗?(java jpasswordfield)
键入密码短语时
yeast bulk seize is shows pain
每个人都能听到敲击空格键的声音,因此在密码字段中显示空格也很合逻辑。所以我想要一些可以显示的东西
***** **** ***** ** ***** ****
代替
******************************
这将使键入更加容易,同时几乎不降低安全性。
更新
更新Riduidel的评论之前请三思。当布鲁斯·施耐尔(Bruce
Schneier)写
“是时候以明文形式显示大多数密码了”时 ,那么显示其中的一小部分也必须是正确的。尤其是显示仅通过聆听即可捕获的部分。
答案1
小编典典这是一种变体,用于setEchoChar()
使密码在预定的时间内可见:例如三秒钟。
import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JFrame;import javax.swing.JPasswordField;import javax.swing.Timer;import javax.swing.event.DocumentEvent;import javax.swing.event.DocumentListener;/** @see http://stackoverflow.com/questions/5339702 */public class PasswordTest { public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGui(); } }); } private static void createAndShowGui() { JFrame jf = new JFrame("Test Password"); JPasswordField jpwd = new JPasswordField(); TimedPasswordListener tpl = new TimedPasswordListener(jpwd); jpwd.getDocument().addDocumentListener(tpl); jf.add(jpwd); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setLocationRelativeTo(null); jf.pack(); jf.setVisible(true); }}class TimedPasswordListener implements DocumentListener, ActionListener { private Timer timer = new Timer(3000, this); private char echoChar; private JPasswordField pwf; public TimedPasswordListener(JPasswordField jp) { pwf = jp; timer.setRepeats(false); } public void insertUpdate(DocumentEvent e) { showText(e); } public void removeUpdate(DocumentEvent e) { showText(e); } public void changedUpdate(DocumentEvent e) {} public void showText(DocumentEvent e) { if (0 != pwf.getEchoChar()) { echoChar = pwf.getEchoChar(); } pwf.setEchoChar((char) 0); timer.restart(); } public void actionPerformed(ActionEvent e) { pwf.setEchoChar(echoChar); }}
.newPassword for SecureField 选择强密码在使用 SwiftUI 和 iOS14 时不起作用
如果您想建议新密码,则需要使用 .newPassword
文本内容类型。
.password
用于输入现有密码。
AFGPasswordTextField
AFGPasswordTextField 介绍
AFGPasswordTextField 是 iOS UITextField 的之类用于密码的输入,你可以自动任何字符作为密码输入时的掩码
AFGPasswordTextFieldDelegate 协议在 API 上兼容 UITextFieldDelegate. 可通过 passwordText
属性来访问密码字符串。
AFGPasswordTextField 官网
https://github.com/daniel-beard/AFGPasswordTextField
com.intellij.ui.components.JBPasswordField的实例源码
private void createuicomponents() { xrayConfig = GlobalSettings.getInstance().getXrayConfig(); url = new JBTextField(); username = new JBTextField(); password = new JBPasswordField(); loadConfig(); }
com.vaadin.ui.PasswordField的实例源码
protected Panel getAttributesPanel() { this.sharedKey = new PasswordField(); this.sharedKey.setrequiredError("shared secret key cannot be empty"); this.sharedKey.setrequired(true); // best show/hide this conditionally based on Manager type. this.sharedKey.setValue("dummy1234"); this.attributes = new Table(); this.attributes.setPageLength(0); this.attributes.setSelectable(true); this.attributes.setSizefull(); this.attributes.setImmediate(true); this.attributes.addContainerProperty("Attribute Name",String.class,null); this.attributes.addContainerProperty("Value",PasswordField.class,null); this.attributes.addItem(new Object[] { "Shared Secret key",this.sharedKey },new Integer(1)); // creating panel to store attributes table this.attributePanel = new Panel("Common Appliance Configuration Attributes:"); this.attributePanel.addStyleName("form_Panel"); this.attributePanel.setWidth(100,Sizeable.Unit.PERCENTAGE); this.attributePanel.setContent(this.attributes); return this.attributePanel; }
protected void initAlfrescoComponent() { alfrescoForm = new Form(); alfrescoForm.setDescription(i18nManager.getMessage(Messages.ALFRESCO_DESCRIPTION)); final TextField alfrescoServer = new TextField(i18nManager.getMessage(Messages.ALFRESCO_SERVER)); alfrescoForm.getLayout().addComponent(alfrescoServer); final TextField alfrescoUserName = new TextField(i18nManager.getMessage(Messages.ALFRESCO_USERNAME)); alfrescoForm.getLayout().addComponent(alfrescoUserName); final PasswordField alfrescopassword = new PasswordField(i18nManager.getMessage(Messages.ALFRESCO_PASSWORD)); alfrescoForm.getLayout().addComponent(alfrescopassword); // Matching listener alfrescoClickListener = new ClickListener() { public void buttonClick(ClickEvent event) { Map<String,Object> accountDetails = createAccountDetails( "alfresco",alfrescoUserName.getValue().toString(),alfrescopassword.getValue().toString(),"server",alfrescoServer.getValue().toString() ); fireEvent(new SubmitEvent(AccountSelectionPopup.this,SubmitEvent.SUBMITTED,accountDetails)); } }; }
protected void initPasswordFields() { inputGrid = new GridLayout(2,2); inputGrid.setSpacing(true); layout.addComponent(inputGrid); layout.setComponentAlignment(inputGrid,Alignment.MIDDLE_CENTER); Label newPasswordLabel = new Label(i18nManager.getMessage(Messages.PROFILE_NEW_PASSWORD)); inputGrid.addComponent(newPasswordLabel); passwordField1 = new PasswordField(); passwordField1.setWidth(150,UNITS_PIXELS); inputGrid.addComponent(passwordField1); passwordField1.focus(); Label confirmPasswordLabel = new Label(i18nManager.getMessage(Messages.PROFILE_CONFIRM_PASSWORD)); inputGrid.addComponent(confirmPasswordLabel); passwordField2 = new PasswordField(); passwordField2.setWidth(150,UNITS_PIXELS); inputGrid.addComponent(passwordField2); }
@Override protected void buildDialogLayout() { Formlayout mainLayout = new Formlayout(); // top-level component properties setWidth("100%"); setHeight("100%"); final PasswordField passwordField = new PasswordField(PASSWORD_LABEL,password); passwordField.setWidth("100%"); mainLayout.addComponent(createTextField(VIRTUOSO_URL_LABEL,virtuosoUrl)); mainLayout.addComponent(createTextField(USERNAME_LABEL,username)); mainLayout.addComponent(passwordField); mainLayout.addComponent(new CheckBox(CLEAR_DESTINATION_GRAPH_LABEL,clearDestinationGraph)); mainLayout.addComponent(createTextField(LOAD_DIRECTORY_PATH_LABEL,loadDirectoryPath)); mainLayout.addComponent(new CheckBox(INCLUDE_SUBDIRECTORIES_LABEL,includeSubdirectories)); mainLayout.addComponent(createTextField(LOAD_FILE_PATTERN_LABEL,loadFilePattern)); mainLayout.addComponent(createTextField(TARGET_CONTEXT_LABEL,targetContext)); mainLayout.addComponent(createTextField(STATUS_UPDATE_INTERVAL_LABEL,statusUpdateInterval)); mainLayout.addComponent(createTextField(THREAD_COUNT_LABEL,threadCount)); mainLayout.addComponent(new CheckBox(SKIP_ON_ERROR_LABEL,skipOnError)); setCompositionRoot(mainLayout); }
@Override public void enter(ViewChangeEvent event) { usernameField = new TextField("Username"); passwordField = new PasswordField("Password"); loginButton = new Button("Login"); loginButton.addClickListener(this); loginButton.setClickShortcut(KeyCode.ENTER); VerticalLayout layout = new VerticalLayout(); setCompositionRoot(layout); layout.setSizefull(); layout.addComponent(usernameField); layout.addComponent(passwordField); layout.addComponent(loginButton); }
private Component buildFields() { HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true); fields.addStyleName("fields"); username = new TextField("Username"); username.setIcon(FontAwesome.USER); username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); username.setTabIndex(1); username.focus(); password = new PasswordField("Password"); password.setIcon(FontAwesome.LOCK); password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); password.setTabIndex(2); final Button signin = new Button("Sign In",this); signin.addStyleName(ValoTheme.BUTTON_PRIMARY); signin.setClickShortcut(KeyCode.ENTER); signin.setTabIndex(4); fields.addComponents(username,password,signin); fields.setComponentAlignment(signin,Alignment.BottOM_LEFT); return fields; }
/** * Setup UI. */ private void initComponents() { userNameInput = new TextField(Messages.getString("LoginPanel.userName"),""); //$NON-NLS-1$ //$NON-NLS-2$ userNameInput.focus(); passwordInput = new PasswordField(Messages.getString("LoginPanel.password"),""); //$NON-NLS-1$ //$NON-NLS-2$ btLogin = new Button(Messages.getString("LoginPanel.login")); //$NON-NLS-1$ btLogin.setClickShortcut(KeyCode.ENTER); Label caption = new Label(Messages.getString("LoginPanel.title"),ContentMode.HTML); //$NON-NLS-1$ caption.addStyleName("login-caption"); //$NON-NLS-1$ addCenteredComponent(caption); addCenteredComponent(userNameInput); addCenteredComponent(passwordInput); addCenteredComponent(btLogin); }
protected void initAlfrescoComponent() { alfrescoForm = new Form(); alfrescoForm.setDescription(i18nManager.getMessage(Messages.ALFRESCO_DESCRIPTION)); final TextField alfrescoServer = new TextField(i18nManager.getMessage(Messages.ALFRESCO_SERVER)); alfrescoForm.getLayout().addComponent(alfrescoServer); final TextField alfrescoUserName = new TextField(i18nManager.getMessage(Messages.ALFRESCO_USERNAME)); alfrescoForm.getLayout().addComponent(alfrescoUserName); final PasswordField alfrescopassword = new PasswordField(i18nManager.getMessage(Messages.ALFRESCO_PASSWORD)); alfrescoForm.getLayout().addComponent(alfrescopassword); // Matching listener alfrescoClickListener = new ClickListener() { public void buttonClick(ClickEvent event) { Map<String,accountDetails)); } }; }
protected void initPasswordFields() { inputGrid = new GridLayout(2,UNITS_PIXELS); inputGrid.addComponent(passwordField2); }
public PasswordField bindPasswordField(String fieldLabel,String fieldName) { PasswordField field = formHelper.bindPasswordField(this,fieldGroup,fieldLabel,fieldName); this.fieldList.add(field); return field; }
@Override public void populateForm() throws Exception { this.providerHttps = new CheckBox("Https"); this.providerHttps.setValue(false); this.rabbitMQIp = new TextField("RabbitMQ IP"); this.rabbitMQUserName = new TextField("RabbitMQ User Name"); this.rabbitMQUserName.setrequired(true); this.rabbitMQUserPassword = new PasswordField("RabbitMQ Password"); this.rabbitMQUserPassword.setrequired(true); this.rabbitMQPort = new TextField("RabbitMQ Port"); this.rabbitMQPort.setrequired(true); this.rabbitMQUserName.setrequiredError(this.rabbitMQUserName.getCaption() + " cannot be empty"); this.rabbitMQUserPassword.setrequiredError(this.rabbitMQUserPassword.getCaption() + " cannot be empty"); this.rabbitMQPort.setrequiredError(this.rabbitMQPort.getCaption() + " cannot be empty"); //fill this form with default/prevIoUs values this.providerHttps.setValue(new Boolean(this.baseVCWindow.providerAttributes.get(ATTRIBUTE_KEY_HTTPS))); if (this.baseVCWindow.providerAttributes.get(ATTRIBUTE_KEY_RABBITMQ_IP) != null) { this.rabbitMQIp.setValue(this.baseVCWindow.providerAttributes.get(ATTRIBUTE_KEY_RABBITMQ_IP)); } if (this.baseVCWindow.providerAttributes.get(ATTRIBUTE_KEY_RABBITMQ_USER) != null) { this.rabbitMQUserName.setValue(this.baseVCWindow.providerAttributes.get(ATTRIBUTE_KEY_RABBITMQ_USER)); } if (this.baseVCWindow.providerAttributes.get(ATTRIBUTE_KEY_RABBITMQ_USER_PASSWORD) != null) { this.rabbitMQUserPassword .setValue(this.baseVCWindow.providerAttributes.get(ATTRIBUTE_KEY_RABBITMQ_USER_PASSWORD)); } if (this.baseVCWindow.providerAttributes.get(ATTRIBUTE_KEY_RABBITMQ_PORT) != null) { this.rabbitMQPort.setValue(this.baseVCWindow.providerAttributes.get(ATTRIBUTE_KEY_RABBITMQ_PORT)); } this.form.addComponent(this.providerHttps); this.form.addComponent(this.rabbitMQIp); this.form.addComponent(this.rabbitMQUserName); this.form.addComponent(this.rabbitMQUserPassword); this.form.addComponent(this.rabbitMQPort); }
protected Panel providerPanel() { this.providerPanel = new Panel(); this.providerPanel.setImmediate(true); this.providerPanel.setCaption(OPENSTACK_CAPTION); this.providerIP = new TextField("IP"); this.providerIP.setImmediate(true); this.adminDomainId = new TextField("Admin Domain Id"); this.adminDomainId.setImmediate(true); this.adminProjectName = new TextField("Admin Project Name"); this.adminProjectName.setImmediate(true); this.providerUser = new TextField("User Name"); this.providerUser.setImmediate(true); this.providerPW = new PasswordField("Password"); this.providerPW.setImmediate(true); // adding not null constraint this.adminDomainId.setrequired(true); this.adminDomainId.setrequiredError(this.providerPanel.getCaption() + " Admin Domain Id cannot be empty"); this.adminProjectName.setrequired(true); this.adminProjectName.setrequiredError(this.providerPanel.getCaption() + " Admin Project Name cannot be empty"); this.providerIP.setrequired(true); this.providerIP.setrequiredError(this.providerPanel.getCaption() + " IP cannot be empty"); this.providerUser.setrequired(true); this.providerUser.setrequiredError(this.providerPanel.getCaption() + " User Name cannot be empty"); this.providerPW.setrequired(true); this.providerPW.setrequiredError(this.providerPanel.getCaption() + " Password cannot be empty"); Formlayout providerFormPanel = new Formlayout(); providerFormPanel.addComponent(this.providerIP); providerFormPanel.addComponent(this.adminDomainId); providerFormPanel.addComponent(this.adminProjectName); providerFormPanel.addComponent(this.providerUser); providerFormPanel.addComponent(this.providerPW); this.providerPanel.setContent(providerFormPanel); return this.providerPanel; }
@Override public void populateForm() { this.loginName = new TextField("User Name"); this.loginName.setImmediate(true); this.firstName = new TextField("First Name"); this.lastName = new TextField("Last Name"); this.password = new PasswordField("Password"); this.password.setImmediate(true); this.email = new TextField("Email"); this.email.addValidator(new EmailValidator("Please enter a valid email address")); this.role = new ComboBox("Role"); this.role.setTextInputAllowed(false); this.role.setNullSelectionAllowed(false); this.role.addItem(UpdateUserWindow.ROLE_ADMIN); this.role.select(UpdateUserWindow.ROLE_ADMIN); // adding not null constraint this.loginName.setrequired(true); this.loginName.setrequiredError("User Name cannot be empty"); this.password.setrequired(true); this.password.setrequiredError("Password cannot be empty"); this.role.setrequired(true); this.form.setMargin(true); this.form.setSizeUndefined(); this.form.addComponent(this.loginName); this.form.addComponent(this.firstName); this.form.addComponent(this.lastName); this.form.addComponent(this.password); this.form.addComponent(this.email); this.form.addComponent(this.role); this.loginName.focus(); }
@Override public void populateForm() throws Exception { this.form.setMargin(true); this.form.setSizeUndefined(); HorizontalLayout layout = new HorizontalLayout(); this.passwordField = new PasswordField(); this.passwordField.setrequired(true); layout.addComponent(this.passwordField); layout.setCaption(Vmidcmessages.getString(Vmidcmessages_.PASSWORD_CAPTION)); this.form.addComponent(layout); }
@Override protected void init(VaadinRequest request) { setSizefull(); user = new TextField("User:"); user.setWidth("300px"); user.setrequiredIndicatorVisible(true); password = new PasswordField("Password:"); password.setWidth("300px"); user.setrequiredIndicatorVisible(true); password.setValue(""); VerticalLayout fields = new VerticalLayout(user,loginButton); fields.setCaption("Please login to access the application"); fields.setSpacing(true); fields.setMargin(new MarginInfo(true,true,false)); fields.setSizeUndefined(); VerticalLayout uiLayout = new VerticalLayout(fields); uiLayout.setSizefull(); uiLayout.setComponentAlignment(fields,Alignment.MIDDLE_CENTER); setFocusedComponent(user); setContent(uiLayout); }
private void addForm() { Formlayout loginForm = new Formlayout(); MessageProvider mp = ServiceContextManager.getServiceContext().getService(MessageProvider.class); username = new TextField(mp.getMessage("default.label.username")); password = new PasswordField(mp.getMessage("default.label.password")); loginForm.addComponents(username,password); addComponent(loginForm); loginForm.setSpacing(true); for(Component component:loginForm){ component.setWidth("100%"); } username.focus(); }
private Component buildFields() { HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true); fields.addStyleName("fields"); final TextField username = new TextField("Username"); username.setIcon(FontAwesome.USER); username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); final PasswordField password = new PasswordField("Password"); password.setIcon(FontAwesome.LOCK); password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); final Button signin = new Button("Sign In"); signin.addStyleName(ValoTheme.BUTTON_PRIMARY); signin.setClickShortcut(KeyCode.ENTER); signin.focus(); fields.addComponents(username,Alignment.BottOM_LEFT); signin.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { DashboardEventBus.post(new UserLoginRequestedEvent(username .getValue(),password.getValue())); } }); return fields; }
private void buildPasswordField() { password = new PasswordField(i18n.getMessage("label.login.password")); password.setIcon(FontAwesome.LOCK); password.addStyleName( ValoTheme.TEXTFIELD_INLINE_ICON + " " + ValoTheme.TEXTFIELD_SMALL + " " + LOGIN_TEXTFIELD); password.setId("login-password"); }
protected void loadUserDetails() { // Grid of details GridLayout detailGrid = new GridLayout(); detailGrid.setColumns(2); detailGrid.setSpacing(true); detailGrid.setMargin(true,false,true); userDetailsLayout.addComponent(detailGrid); // Details addUserDetail(detailGrid,i18nManager.getMessage(Messages.USER_ID),new Label(user.getId())); // details are non-editable if (!editingDetails) { addUserDetail(detailGrid,i18nManager.getMessage(Messages.USER_FirsTNAME),new Label(user.getFirstName())); addUserDetail(detailGrid,i18nManager.getMessage(Messages.USER_LASTNAME),new Label(user.getLastName())); addUserDetail(detailGrid,i18nManager.getMessage(Messages.USER_EMAIL),new Label(user.getEmail())); } else { firstNameField = new TextField(null,user.getFirstName() != null ? user.getFirstName() : ""); addUserDetail(detailGrid,firstNameField); firstNameField.focus(); lastNameField = new TextField(null,user.getLastName() != null ? user.getLastName() : ""); addUserDetail(detailGrid,lastNameField); emailField = new TextField(null,user.getEmail() != null ? user.getEmail() : ""); addUserDetail(detailGrid,emailField); passwordField = new PasswordField(); Label cautionLabel = new Label(i18nManager.getMessage(Messages.USER_RESET_PASSWORD)); cautionLabel.addStyleName(Reindeer.LABEL_SMALL); HorizontalLayout passwordLayout = new HorizontalLayout(); passwordLayout.setSpacing(true); passwordLayout.addComponent(passwordField); passwordLayout.addComponent(cautionLabel); passwordLayout.setComponentAlignment(cautionLabel,Alignment.MIDDLE_LEFT); addUserDetail(detailGrid,i18nManager.getMessage(Messages.USER_PASSWORD),passwordLayout); } }
@Override protected void buildDialogLayout() { setSizefull(); final VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setHeight("-1px"); mainLayout.setMargin(true); mainLayout.setSpacing(true); mainLayout.setWidth("100%"); uri = new TextField(ctx.tr("FilesuploadVaadindialog.uri")); uri.setDescription(ctx.tr("FilesuploadVaadindialog.uri.description")); uri.setrequired(true); uri.setrequiredError(ctx.tr("FilesuploadVaadindialog.uri.required")); uri.setWidth("100%"); mainLayout.addComponent(uri); username = new TextField(ctx.tr("FilesuploadVaadindialog.username")); username.setWidth("75%"); mainLayout.addComponent(username); password = new PasswordField(ctx.tr("FilesuploadVaadindialog.password")); password.setWidth("75%"); mainLayout.addComponent(password); softFail = new CheckBox(ctx.tr("FilesuploadVaadindialog.skip")); softFail.setWidth("100%"); mainLayout.addComponent(softFail); moveFiles = new CheckBox(ctx.tr("FilesuploadVaadindialog.move")); moveFiles.setWidth("100%"); mainLayout.addComponent(moveFiles); setCompositionRoot(mainLayout); }
private void buildForm() { username = new TextField("Username"); username.setWidth("100%"); username.setImmediate(true); username.setValidationVisible(false); username.setNullRepresentation(""); username.setrequired(true); form.addComponent(username); password = new PasswordField("Password"); password.setWidth("100%"); password.setImmediate(true); password.setValidationVisible(false); password.setNullRepresentation(""); password.setrequired(true); form.addComponent(password); firstName = new TextField("First name"); firstName.setWidth("100%"); firstName.setValidationVisible(false); firstName.setNullRepresentation(""); firstName.setImmediate(true); firstName.setrequired(true); form.addComponent(firstName); lastName = new TextField("Last name"); lastName.setWidth("100%"); lastName.setImmediate(true); lastName.setNullRepresentation(""); lastName.setValidationVisible(false); lastName.setrequired(true); form.addComponent(lastName); binder.bind(username,"username"); binder.bind(password,"password"); binder.bind(firstName,"firstName"); binder.bind(lastName,"lastName"); }
private void initUI() { final MVerticalLayout mainLayout = new MVerticalLayout().withFullWidth(); final Label lbInstruct1 = new Label(UserUIContext.getMessage(UserI18nEnum.MSG_PASSWORD_INSTRUCT_LABEL_1)); mainLayout.addComponent(lbInstruct1); mainLayout.setComponentAlignment(lbInstruct1,Alignment.MIDDLE_LEFT); final Label lbInstruct2 = new Label(UserUIContext.getMessage(UserI18nEnum.MSG_PASSWORD_INSTRUCT_LABEL_2)); mainLayout.addComponent(lbInstruct2); mainLayout.setComponentAlignment(lbInstruct2,Alignment.MIDDLE_LEFT); GridFormlayoutHelper passInfo = GridFormlayoutHelper.defaultFormlayoutHelper(1,3); txtNewPassword = new PasswordField(); passInfo.addComponent(txtNewPassword,UserUIContext.getMessage(ShellI18nEnum.OPT_NEW_PASSWORD),0); txtConfirmPassword = new PasswordField(); passInfo.addComponent(txtConfirmPassword,UserUIContext.getMessage(ShellI18nEnum.OPT_CONFIRMED_PASSWORD),1); mainLayout.addComponent(passInfo.getLayout()); mainLayout.setComponentAlignment(passInfo.getLayout(),Alignment.MIDDLE_CENTER); MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL),clickEvent -> close()) .withStyleName(WebThemes.BUTTON_OPTION); MButton saveBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE),clickEvent -> changePassword()) .withIcon(FontAwesome.SAVE).withStyleName(WebThemes.BUTTON_ACTION).withClickShortcut(ShortcutAction.KeyCode.ENTER); MHorizontalLayout hlayoutControls = new MHorizontalLayout(cancelBtn,saveBtn).withMargin(new MarginInfo(false,true)); mainLayout.with(hlayoutControls).withAlign(hlayoutControls,Alignment.MIDDLE_RIGHT); this.setContent(mainLayout); }
private void buildForm() { username = new TextField("Username"); username.setWidth("100%"); username.setImmediate(true); username.setValidationVisible(false); username.setNullRepresentation(""); form.addComponent(username); password = new PasswordField("Password"); password.setWidth("100%"); password.setImmediate(true); password.setValidationVisible(false); password.setNullRepresentation(""); form.addComponent(password); firstName = new TextField("First name"); firstName.setWidth("100%"); firstName.setValidationVisible(false); firstName.setNullRepresentation(""); firstName.setImmediate(true); form.addComponent(firstName); lastName = new TextField("Last name"); lastName.setWidth("100%"); lastName.setImmediate(true); lastName.setNullRepresentation(""); lastName.setValidationVisible(false); form.addComponent(lastName); binder.bind(username,"lastName"); }
protected void loadUserDetails() { // Grid of details GridLayout detailGrid = new GridLayout(); detailGrid.setColumns(2); detailGrid.setSpacing(true); detailGrid.setMargin(true,passwordLayout); } }
/** {@inheritDoc} */ @Override protected ComponentContainer createEditFields() { final Formlayout form = new ExtaFormlayout(); passField = new PasswordField("Пароль"); // passField.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); // passField.setIcon(Fontello.LOCK); passField.setImmediate(true); passField.setDescription("Введите пароль для входа в систему"); passField.setInputPrompt("Пароль"); passField.setrequired(true); passField.setrequiredError("Пароль пользователя не может быть пустым."); passField.setNullRepresentation(""); form.addComponent(passField); passConfField = new PasswordField("Подтверждение пароля"); // passConfField.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); // passConfField.setIcon(Fontello.LOCK); passConfField.setImmediate(true); passConfField.setDescription("Введите повторно пароль для для его подтвержедения"); passConfField.setInputPrompt("Подтверждение пароля"); passConfField.setrequired(true); passConfField.setNullRepresentation(""); // Todo: Сделать симметричную проверку пароля passConfField.addValidator(new Validator() { private static final long serialVersionUID = 1L; @Override public void validate(final Object value) throws InvalidValueException { if (!value.equals(passField.getValue())) throw new InvalidValueException("Пароли не совпадают!"); } }); passConfField.setValue(getEntity().getpassword()); form.addComponent(passConfField); return form; }
private void setVisibleFields(final OptionGroup group,final TextField tfKeyFile,final TextField tfProxyHost,final TextField tfProxyPort,final TextField tfUser,final PasswordField tfPw) { if (group.getValue() == null) group.setValue("FILE"); String strGroup = group.getValue().toString(); if (strGroup == "FTP") { tfKeyFile.setVisible(false); tfProxyHost.setVisible(false); tfProxyPort.setVisible(false); tfUser.setVisible(true); tfPw.setVisible(true); } else if (strGroup == "SFTP") { tfKeyFile.setVisible(true); tfProxyHost.setVisible(true); tfProxyPort.setVisible(true); tfUser.setVisible(true); tfPw.setVisible(true); } else { // File tfKeyFile.setVisible(false); tfProxyHost.setVisible(false); tfProxyPort.setVisible(false); tfUser.setVisible(false); tfPw.setVisible(false); } }
private void forms(CssLayout container) { VerticalLayout form = new VerticalLayout(); form.addStyleName(Bootstrap.Forms.FORM.styleName()); form.setSpacing(true); 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); }
public <M> PasswordField bindPasswordField(AbstractLayout form,FieldGroup group,String fieldLabel,Singularattribute<E,M> member) { PasswordField field = bindPasswordField(form,group,(member != null ? member.getName() : null)); this.fieldList.add(field); return field; }
public PasswordField bindPasswordField(AbstractLayout form,String fieldName) { PasswordField field = new SplitPasswordField(fieldLabel); field.setWidth("100%"); field.setImmediate(true); field.setNullRepresentation(""); field.setNullSettingallowed(false); field.setId(fieldLabel.replace(" ","")); addValuechangelisteners(field); dobinding(group,fieldName,field); form.addComponent(field); return field; }
public PasswordField bindPasswordField(String fieldLabel,String> fieldName) { PasswordField field = formHelper.bindPasswordField(this,fieldName); this.fieldList.add(field); return field; }
/** * Adds a text field to the form without binding it to the FieldGroup * * @param caption * @return */ public PasswordField addPasswordField(String fieldLabel) { PasswordField field = formHelper.bindPasswordField(this,(ValidatingFieldGroup<?>) null,(Singularattribute<E,String>) null); this.fieldList.add(field); return field; }
/** * Create a new {@link PasswordField} * @return new PasswordField with null representation set to emptry string. */ public static PasswordField newPasswordField() { PasswordField pf = new PasswordField(); pf.setNullRepresentation(""); return pf; }
static BiFunction<Class,String,String> passwordID() { return (uiClass,label) -> genericID().apply(uiClass,label); }
protected Panel controllerPanel() { this.controllerPanel = new Panel(); this.controllerPanel.setImmediate(true); this.controllerPanel.setCaption(SDN_CONTROLLER_CAPTION); this.controllerType = new ComboBox("Type"); this.controllerType.setTextInputAllowed(false); this.controllerType.setNullSelectionAllowed(false); this.controllerType.addItem(NO_CONTROLLER_TYPE); for (String ct : this.pluginService.getControllerTypes()) { this.controllerType.addItem(ct); } this.controllerType.setVisible(true); this.controllerIP = new TextField("IP"); this.controllerIP.setImmediate(true); this.controllerUser = new TextField("User Name"); this.controllerUser.setImmediate(true); this.controllerPW = new PasswordField("Password"); this.controllerPW.setImmediate(true); // adding not null constraint this.controllerIP.setrequired(true); this.controllerIP.setrequiredError(this.controllerPanel.getCaption() + " IP cannot be empty"); this.controllerUser.setrequired(true); this.controllerUser.setrequiredError(this.controllerPanel.getCaption() + " User Name cannot be empty"); this.controllerPW.setrequired(true); this.controllerPW.setrequiredError(this.controllerPanel.getCaption() + " Password cannot be empty"); Formlayout sdn = new Formlayout(); sdn.addComponent(this.controllerType); sdn.addComponent(this.controllerIP); sdn.addComponent(this.controllerUser); sdn.addComponent(this.controllerPW); this.controllerPanel.setContent(sdn); this.controllerType.addValuechangelistener(event -> updateControllerFields((String) BaseVCWindow.this.controllerType.getValue())); this.controllerType.select(NO_CONTROLLER_TYPE); return this.controllerPanel; }
@Override public void populateForm() throws Exception { this.name = new TextField("Name"); this.name.setImmediate(true); this.type = new TextField("Type"); this.type.setImmediate(true); this.type.setEnabled(false); this.ip = new TextField("IP"); this.ip.setImmediate(true); this.user = new TextField("UserName"); this.user.setImmediate(true); this.pw = new PasswordField("Password"); this.pw.setImmediate(true); this.apiKey = new PasswordField("API Key"); this.apiKey.setVisible(false); this.apiKey.setImmediate(true); this.apiKey.setrequired(true); this.apiKey.setrequiredError("Api Key cannot be empty"); // filling fields with existing information this.name.setValue(this.currentMCObject.getItemProperty("name").getValue().toString()); this.type.setValue(this.currentMCObject.getItemProperty("managerType").getValue().toString()); this.ip.setValue(this.currentMCObject.getItemProperty("ipAddress").getValue().toString()); if (this.pluginService.isKeyAuth(this.currentMCObject.getItemProperty("managerType") .getValue().toString())) { this.apiKey.setVisible(true); this.apiKey.setValue(this.currentMCObject.getItemProperty("apiKey").getValue().toString()); this.user.setVisible(false); this.user.setValue(""); this.pw.setVisible(false); this.pw.setValue(""); } else { this.apiKey.setVisible(false); this.user.setVisible(true); this.user.setValue(this.currentMCObject.getItemProperty("username").getValue().toString()); this.pw.setVisible(true); this.pw.setValue(this.currentMCObject.getItemProperty("password").getValue().toString()); } // adding not null constraint this.name.setrequired(true); this.name.setrequiredError("Name cannot be empty"); this.type.setrequired(true); this.type.setrequiredError("Type cannot be empty"); this.ip.setrequired(true); this.ip.setrequiredError("IP cannot be empty"); this.user.setrequired(true); this.user.setrequiredError("User Name cannot be empty"); this.pw.setrequired(true); this.pw.setrequiredError("Password cannot be empty"); this.form.setMargin(true); this.form.setSizeUndefined(); this.form.addComponent(this.name); this.form.addComponent(this.type); this.form.addComponent(this.ip); this.ip.focus(); this.form.addComponent(this.user); this.form.addComponent(this.pw); this.form.addComponent(this.apiKey); }
@Override public void populateForm() { this.loginName = new TextField("User Name"); this.loginName.setImmediate(true); this.firstName = new TextField("First Name"); this.lastName = new TextField("Last Name"); this.password = new PasswordField("Password"); this.password.setImmediate(true); this.email = new TextField("Email"); this.email.addValidator(new EmailValidator("Please enter a valid email address")); this.role = new ComboBox("Role"); this.role.setTextInputAllowed(false); this.role.setNullSelectionAllowed(false); this.role.addItem(UpdateUserWindow.ROLE_ADMIN); this.role.select(UpdateUserWindow.ROLE_ADMIN); // filling fields with existing information this.loginName.setValue(this.currentUser.getItemProperty("loginName").getValue().toString()); this.loginName.setEnabled(false); this.password.setValue(this.currentUser.getItemProperty("password").getValue().toString()); if (this.currentUser.getItemProperty("email").getValue() != null) { this.email.setValue(this.currentUser.getItemProperty("email").getValue().toString()); } if (this.currentUser.getItemProperty("firstName").getValue() != null) { this.firstName.setValue(this.currentUser.getItemProperty("firstName").getValue().toString()); } if (this.currentUser.getItemProperty("lastName").getValue() != null) { this.lastName.setValue(this.currentUser.getItemProperty("lastName").getValue().toString()); } this.role.setValue(this.currentUser.getItemProperty("role").getValue().toString()); // adding not null constraint this.loginName.setrequired(true); this.loginName.setrequiredError("User Name cannot be Empty"); this.password.setrequired(true); this.password.setrequiredError("Password Cannot be empty"); this.role.setrequired(true); this.form.setMargin(true); this.form.setSizeUndefined(); this.form.addComponent(this.loginName); this.form.addComponent(this.firstName); this.form.addComponent(this.lastName); this.form.addComponent(this.password); this.form.addComponent(this.email); this.form.addComponent(this.role); this.firstName.focus(); }
@Override public void populateForm() { this.smtp = new TextField("Outgoing Mail Server (SMTP)"); this.smtp.setImmediate(true); this.port = new TextField("Port"); this.port.setImmediate(true); this.emailId = new TextField("Email Id"); this.emailId.setImmediate(true); this.password = new PasswordField("Password"); this.password.setImmediate(true); // filling form with existing data BaseDtoResponse<EmailSettingsDto> res = new BaseDtoResponse<EmailSettingsDto>(); try { res = this.getEmailSettingsService.dispatch(new Request() { }); if (res.getDto() != null) { this.smtp.setValue(res.getDto().getMailServer()); this.port.setValue(res.getDto().getPort()); this.emailId.setValue(res.getDto().getEmailId()); this.password.setValue(res.getDto().getpassword()); } // adding not null constraint this.smtp.setrequired(true); this.smtp.setrequiredError("SMTP server cannot be empty"); this.port.setrequired(true); this.port.setrequiredError("SMTP port cannot be empty"); this.emailId.setrequired(true); this.emailId.setrequiredError("Email Id cannot be empty"); this.form.addComponent(this.smtp); this.smtp.focus(); this.form.addComponent(this.port); this.form.addComponent(this.emailId); this.form.addComponent(this.password); } catch (Exception ex) { log.error("Failed to get email settings",ex); ViewUtil.iscNotification("Failed to get email settings (" + ex.getMessage() + ")",Notification.Type.ERROR_MESSAGE); } }
static BiFunction<Class,label); }
@SuppressWarnings("serial") @Override protected void init(VaadinRequest request) { getUI().setLocale(BBPlay.getLanguage(request.getLocale().getLanguage())); I18n.init(i18n); getPage().setTitle("BBPlay"); String token = request.getParameter("token"); if (token == null || token.isEmpty()) { BBPlay.error(I18n.t("noToken")); return; } User user = userService.checkToken(token); if (user == null) { BBPlay.error(I18n.t("wrongPasswordToken")); return; } Formlayout loginForm = new Formlayout(); loginForm.setSizeUndefined(); passwordField = new PasswordField(I18n.t("changePassword.new")); passwordFieldRepeat = new PasswordField(I18n.t("changePassword.confirm")); passwordFieldRepeat.setImmediate(false); passwordFieldRepeat.addValidator(new AbstractStringValidator(I18n .t("changePassword.errorMatch")) { @Override protected boolean isValidValue(String value) { return value.equals(passwordField.getValue()); } }); reset = new Button(I18n.t("reset")); loginForm.addComponent(passwordField); loginForm.addComponent(passwordFieldRepeat); loginForm.addComponent(reset); reset.addStyleName(ValoTheme.BUTTON_PRIMARY); reset.setClickShortcut(ShortcutAction.KeyCode.ENTER); reset.addClickListener(event -> reset(user)); VerticalLayout loginLayout = new VerticalLayout(); loginLayout.setSpacing(true); loginLayout.setSizeUndefined(); 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(); }
关于JPasswordField可以替代吗?和java jpasswordfield的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于.newPassword for SecureField 选择强密码在使用 SwiftUI 和 iOS14 时不起作用、AFGPasswordTextField、com.intellij.ui.components.JBPasswordField的实例源码、com.vaadin.ui.PasswordField的实例源码等相关内容,可以在本站寻找。
本文标签: