コード例 #1
0
  private void checkInput() {
    if (0 == userNameField.getText().trim().length()) {
      JOptionPane.showMessageDialog(this, "用户名不能为空", "警告", JOptionPane.WARNING_MESSAGE);
      userNameField.requestFocus();
      return;
    }

    if (0 == passwordField.getPassword().length) {
      JOptionPane.showMessageDialog(this, "密码不能为空", "警告", JOptionPane.WARNING_MESSAGE);
      passwordField.requestFocus();
      return;
    }

    if (!new String(confirmPasswordField.getPassword())
        .equals(new String(passwordField.getPassword()))) {
      JOptionPane.showMessageDialog(this, "两次密码不相同", "警告", JOptionPane.WARNING_MESSAGE);
      passwordField.requestFocus();
      return;
    }

    if (0 == nickNameField.getText().trim().length()) {
      JOptionPane.showMessageDialog(this, "昵称不能为空", "警告", JOptionPane.WARNING_MESSAGE);
      nickNameField.requestFocus();
      return;
    }
  }
コード例 #2
0
  /** Modifies the existing password. */
  private void changePassword() {
    UserNotifier un;
    if (!oldPassword.isVisible()) {
      StringBuffer buf = new StringBuffer();
      buf.append(passwordNew.getPassword());
      String newPass = buf.toString();
      if (newPass == null || newPass.length() == 0) {
        un = MetadataViewerAgent.getRegistry().getUserNotifier();
        un.notifyInfo(PASSWORD_CHANGE_TITLE, "Please enter the new password.");
        passwordNew.requestFocus();
        return;
      }
      un = MetadataViewerAgent.getRegistry().getUserNotifier();
      un.notifyInfo(PASSWORD_CHANGE_TITLE, "Password changed.");
      passwordNew.setText("");
      model.resetPassword(newPass);
      return;
    }
    StringBuffer buf = new StringBuffer();
    buf.append(passwordNew.getPassword());
    String newPass = buf.toString();

    String pass = buf.toString();
    buf = new StringBuffer();
    buf.append(passwordConfirm.getPassword());
    String confirm = buf.toString();

    buf = new StringBuffer();
    buf.append(oldPassword.getPassword());
    String old = buf.toString();
    if (old == null || old.trim().length() == 0) {
      un = MetadataViewerAgent.getRegistry().getUserNotifier();
      un.notifyInfo(PASSWORD_CHANGE_TITLE, "Please specify your old password.");
      oldPassword.requestFocus();
      return;
    }
    if (newPass == null || newPass.length() == 0) {
      un = MetadataViewerAgent.getRegistry().getUserNotifier();
      un.notifyInfo(PASSWORD_CHANGE_TITLE, "Please enter your new password.");
      passwordNew.requestFocus();
      return;
    }

    if (pass == null || confirm == null || confirm.length() == 0 || !pass.equals(confirm)) {
      un = MetadataViewerAgent.getRegistry().getUserNotifier();
      un.notifyInfo(
          PASSWORD_CHANGE_TITLE, "The passwords entered do not match. " + "Please try again.");
      passwordNew.setText("");
      passwordConfirm.setText("");
      passwordNew.requestFocus();
      return;
    }
    model.changePassword(old, confirm);
  }
コード例 #3
0
 /**
  * Sets the focus on the user name field if no user name entered otherwise, sets the focus on the
  * password field.
  */
 public void requestFocusOnField() {
   if (loginAttempt) return;
   setControlsEnabled(true);
   String txt = user.getText();
   if (txt == null || txt.trim().length() == 0) user.requestFocus();
   else pass.requestFocus();
 }
コード例 #4
0
  protected Component createDesign(String text) {
    //      System.out.println ("createDesign("+text+")"+this+" "+System.identityHashCode(this)); //
    // NOI18N
    JPanel panel = new JPanel();
    JLabel textLabel = new JLabel(text);
    textLabel.setBorder(new EmptyBorder(0, 0, 0, 10));
    panel.setLayout(new BorderLayout());
    panel.setBorder(new EmptyBorder(10, 10, 6, 6));
    panel.add("West", textLabel); // NOI18N
    passwordField = new javax.swing.JPasswordField(25);
    //      System.out.println("passwordField: "+passwordField); // NOI18N
    panel.add("Center", passwordField); // NOI18N
    passwordField.setBorder(
        new CompoundBorder(passwordField.getBorder(), new EmptyBorder(2, 0, 2, 0)));
    passwordField.requestFocus();

    javax.swing.KeyStroke enter =
        javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ENTER, 0);
    javax.swing.text.Keymap map = passwordField.getKeymap();

    map.removeKeyStrokeBinding(enter);
    /*
    passwordField.addActionListener (new java.awt.event.ActionListener () {
        public void actionPerformed (java.awt.event.ActionEvent evt) {
          NotifyDescriptorInputPassword.this.setValue (NotifyDescriptor.InputLine.OK_OPTION);
        }
      }
    );
    */
    return panel;
  }
コード例 #5
0
ファイル: ExtPasswordField.java プロジェクト: munix/jdget
 /*
  * (non-Javadoc)
  *
  * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
  */
 @Override
 public void focusGained(final FocusEvent e) {
   if (e.getSource() == renderer) {
     setRendererMode(false);
     editor.requestFocus();
   } else {
     setEditorText(renderer.getText());
     editor.selectAll();
   }
 }
コード例 #6
0
ファイル: CatPassword.java プロジェクト: KIFTERKON/josedg
        public void actionPerformed(ActionEvent e) {
          if (!txtFolio.getText().equals("")) {
            Obj_Usuario usuario = new Obj_Usuario();
            usuario = usuario.buscar(Integer.parseInt(txtFolio.getText()));

            if (usuario.getFolio() != 0) {
              txtNombre.setText(usuario.getNombre_completo());
              pxpClave.requestFocus();
            } else {
              JOptionPane.showMessageDialog(
                  null, "El usuario no existe", "Aviso", JOptionPane.WARNING_MESSAGE);
              return;
            }
          } else {
            JOptionPane.showMessageDialog(
                null, "Ingrese el Folio del Usuario", "Aviso", JOptionPane.WARNING_MESSAGE);
            return;
          }
        }
コード例 #7
0
ファイル: LoginForm_1.java プロジェクト: JJMSoft/ChurchApp
  private boolean validateData() {

    if (txtUser.getText().trim().length() == 0) {
      JOptionPane.showMessageDialog(
          null,
          ConstantMessages.REQUIRED_USERNAME,
          ConstantMessages.ERROR_TITLE,
          ConstantMessages.ERROR_ICON);
      txtUser.requestFocus();
      return false;
    }

    if (txtPassword.getText().trim().length() == 0) {
      JOptionPane.showMessageDialog(
          null,
          ConstantMessages.REQUIRED_PASSWORD,
          ConstantMessages.ERROR_TITLE,
          ConstantMessages.ERROR_ICON);
      txtPassword.requestFocus();
      return false;
    }

    return true;
  }