예제 #1
0
 /** Focus password field if last login name is present in config. */
 public final void focusField() {
   String lastUser = userPrefs.get("login.lastUser", null);
   if (lastUser != null) {
     fldusername.setText(lastUser);
     pfpassword.requestFocusInWindow();
   }
 }
예제 #2
0
  public boolean validarCampos() {

    boolean resp = true;
    int clv;

    usuario = txtusuario.getText();
    clave = new String(txtclave.getPassword());

    // si usuario esta vacio
    if (usuario.trim().length() == 0) {
      JOptionPane.showMessageDialog(
          this,
          "Por favor Ingrese el Usuario",
          "Campo Usuario (Obligatorio)",
          JOptionPane.ERROR_MESSAGE);
      resp = txtusuario.requestFocusInWindow();
      return resp;
    }
    // si clave esta vacio
    if (clave.trim().length() == 0) {
      JOptionPane.showMessageDialog(
          this,
          "Por favor ingrese la clave",
          "Campo Contraseña (Obligatorio)",
          JOptionPane.ERROR_MESSAGE);
      resp = false;
      return resp;
    }
    if (usuario.trim().length() < 3 || usuario.trim().length() > 20) {
      JOptionPane.showMessageDialog(
          this,
          "Debe ingresar mínimo 3 caracteres " + "y máximo 20",
          "Campo Usuario (Obligatorio)",
          JOptionPane.ERROR_MESSAGE);
      txtusuario.setText("");
      txtclave.setText("");
      txtusuario.requestFocusInWindow();
      resp = false;
      return resp;
    }

    if (clave.trim().length() < 3 || clave.trim().length() > 16) {
      JOptionPane.showMessageDialog(
          this,
          "Debe ingresar mínimo 3 caracteres " + "y máximo 16",
          "Campo Clave (Obligatorio)",
          JOptionPane.ERROR_MESSAGE);
      txtclave.setText("");
      txtclave.requestFocusInWindow();
      resp = false;
      return resp;
    }

    return resp;
  }
 protected void resetFocus() {
   passwordField.requestFocusInWindow();
 }