/** * Set echo character. * * @param c * Echo character */ public void setEchoChar(char c) { jpfPassword.setEchoChar(c); }
private void makePasswordInvisible() { myPasswordField.setEchoChar('•'); }
private void makePasswordVisible() { myPasswordField.setEchoChar('\u0000'); }
@Override public void actionPerformed(java.awt.event.ActionEvent e) { if (chkShowPassword.isSelected()) { txtProxyChainPassword.setEchoChar((char) 0); } else { txtProxyChainPassword.setEchoChar('*'); } } });
@Override public void actionPerformed(java.awt.event.ActionEvent e) { if (chkShowPassword.isSelected()) { txtProxyChainPassword.setEchoChar((char) 0); } else { txtProxyChainPassword.setEchoChar('*'); } } });
public void stateChanged(ChangeEvent e) { tfpass.setEchoChar(cbshowchars.isSelected() ? 0 : echo); } });
public void stateChanged(ChangeEvent e) { tfpass.setEchoChar(cbshowchars.isSelected() ? 0 : echo); } });
JPasswordField password = new JPasswordField(15); { password.setEchoChar('%'); }
JPasswordField p1=new JPasswordField("pass",6); p1.setEchoChar('*'); top.add(p1);
JPasswordField user = new JPasswordField(10); user.setEchoChar('?'); panel.add(user);
private void showPasswordCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_showPasswordCheckBoxItemStateChanged if (showPasswordCheckBox.isSelected()) { passwordPasswordField.setEchoChar((char) 0); } else { passwordPasswordField.setEchoChar(reference.getEchoChar()); } }//GEN-LAST:event_showPasswordCheckBoxItemStateChanged
@Override public void actionPerformed(ActionEvent e) { JButton button = (JButton) e.getSource(); if (asClearText) { ButtonDecorator.applyShow(button); } else { ButtonDecorator.applyHide(button); } asClearText = !asClearText; if (asClearText) { // Reveal password1.setEchoChar('\0'); password2.setEchoChar('\0'); } else { // Use the platform choice password1.setEchoChar(echoChar); password2.setEchoChar(echoChar); } }
@Override public void setEchoChar(char echoChar) { getSwingComponent().setEchoChar(echoChar); }
public JPasswordFieldTutorial() { button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { char [] input = passwordField.getPassword(); if(checkIfCorrect(input)) { JOptionPane.showMessageDialog(null,"Password is correct!"); } else { JOptionPane.showMessageDialog(null,"Password is incorrect!"); } } }); passwordField.setEchoChar('*'); panel.add(passwordField); panel.add(button); frame.add(panel); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.pack(); frame.setVisible(true); }
@Override public void actionPerformed(ActionEvent e) { JButton button = (JButton) e.getSource(); if (asClearText) { ButtonDecorator.applyShow(button); } else { ButtonDecorator.applyHide(button); } asClearText = !asClearText; if (asClearText) { // Reveal password.setEchoChar('\0'); } else { // Use the platform choice password.setEchoChar(echoChar); } }
private void showButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showButtonActionPerformed if (!passwordVisible) { passwordVisible = true; originalFont = passwordField.getFont(); passwordField.setFont(usernameTextField.getFont()); originalEchoChar = passwordField.getEchoChar(); passwordField.setEchoChar((char) 0); Mnemonics.setLocalizedText(showButton, NbBundle.getMessage(CustomizerGeneral.class, "LBL_ShowButtonHide")); showButton.setToolTipText(NbBundle.getMessage(CustomizerGeneral.class, "LBL_ShowButtonHide_ToolTip")); } else { passwordVisible = false; passwordField.setFont(originalFont); passwordField.setEchoChar(originalEchoChar); Mnemonics.setLocalizedText(showButton, NbBundle.getMessage(CustomizerGeneral.class, "CustomizerGeneral.showButton.text")); showButton.setToolTipText(NbBundle.getMessage(CustomizerGeneral.class, "CustomizerGeneral.showButton.toolTipText")); } }//GEN-LAST:event_showButtonActionPerformed
final JPasswordField pass = new JPasswordField("Password"); Font passFont = user.getFont(); pass.setFont(passFont.deriveFont(Font.ITALIC)); pass.setForeground(Color.GRAY); pass.setPreferredSize(new Dimension(150, 20)); pass.setEchoChar((char)0); pass.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { pass.setEchoChar('*'); if (pass.getText().equals("Password")) { pass.setText(""); } } public void focusLost(FocusEvent e) { if ("".equalsIgnoreCase(pass.getText().trim())) { pass.setEchoChar((char)0); pass.setText("Password"); } }});
private JPasswordField password; private String typedPassword; private final String defaultPassword = "yourDesiredPassword"; public void createPasswordField(){ password = new JPasswordField(30); password.setBounds(280, 240, 90, 20); password.setEchoChar('*'); password.setBackground(Color.white); password.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { password = (JPasswordField) e.getSource(); char [] tempPass = password.getPassword(); typedPassword = new String(tempPass); if (!typedPassword.equals(defaultPassword)){ JOptionPane.showMessageDialog(null, "Your password is not correct", "Stack Over Flow example", JOptionPane.ERROR_MESSAGE); } } }); }
@Override public void initParam(Object obj) { OptionsParam optionsParam = (OptionsParam) obj; ConnectionParam connectionParam = optionsParam.getConnectionParam(); // set Proxy Chain parameters txtProxyChainRealm.setText(connectionParam.getProxyChainRealm()); txtProxyChainRealm.discardAllEdits(); txtProxyChainUserName.setText(connectionParam.getProxyChainUserName()); txtProxyChainUserName.discardAllEdits(); chkShowPassword.setSelected(false);//Default don't show (everytime) txtProxyChainPassword.setEchoChar('*');//Default mask (everytime) this.proxyDialog.pack(); }
@Override JPasswordField initSwingComponent() { TextField textField = getAWTComponent(); JPasswordField swingComponent = new JPasswordField(); swingComponent.setText(textField.getText()); swingComponent.setColumns(textField.getColumns()); swingComponent.setEchoChar(textField.getEchoChar()); swingComponent.setEditable(textField.isEditable()); swingComponent.select(textField.getSelectionStart(), textField.getSelectionEnd()); swingComponent.addActionListener(new SwingTextFieldListener()); return swingComponent; }