Beispiel #1
0
 private void checkLogin() {
   // 对输入进行基本的合法非法判断
   String id = idTxt.getText();
   String passwd = String.valueOf(passwordTxt.getPassword());
   ResultMessage idResult = Utility.checkInputValid(id, 4, 14, false);
   ResultMessage passwdResult = Utility.checkInputValid(passwd, 5, 14, false);
   if (idResult != ResultMessage.SUCCESS) {
     MyOptionPane.showMessageDialog(null, "输入的用户名" + idResult.toFriendlyString() + "!");
     return;
   } else if (passwdResult != ResultMessage.SUCCESS) {
     MyOptionPane.showMessageDialog(null, "输入的密码" + passwdResult.toFriendlyString() + "!");
     return;
   }
   // 登录验证
   ResultMessage loginresult = loginController.login(usertype.getSelectedIndex(), id, passwd);
   if (loginresult == ResultMessage.SUCCESS) {
     new HomeUI(loginController);
     frame.dispose();
   } else {
     if (loginresult == ResultMessage.WRONG_ID) {
       MyOptionPane.showMessageDialog(null, "用户名错误!");
       idTxt.setText("");
       passwordTxt.setText("");
     } else if (loginresult == ResultMessage.WRONG_PASSWD) {
       MyOptionPane.showMessageDialog(null, "密码错误!");
       passwordTxt.setText("");
     } else {
       MyOptionPane.showMessageDialog(null, "服务器未开启!");
     }
   }
 }
  public void actionPerformed(ActionEvent ae) {
    if (ae.getSource() == b1) {
      try {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        Connection con =
            DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "system", "123");
        PreparedStatement ps =
            con.prepareStatement("select * from LoginForm where username=? and password=?");
        String UserName = t1.getText();
        String Password = jp1.getText();
        ps.setString(1, UserName);
        ps.setString(2, Password);
        ResultSet rs = ps.executeQuery();
        boolean flag = rs.next();
        if (flag) {
          new Main();
          f.setVisible(false);
        } else {
          JOptionPane.showMessageDialog(null, "Please Enter valid Name And Password");
        }

      } catch (Exception e) {
        System.out.println("Error:" + e);
      }
    } else if (ae.getSource() == b2) {
      t1.setText("");
      jp1.setText("");
    } else if (ae.getSource() == b3) {

      f.setVisible(false);
    }
  }
Beispiel #3
0
 public char[] askPassword() {
   char[] password = null;
   final JDialog dlg = new JDialog(frm, "Password", true);
   final JPasswordField jpf = new JPasswordField(15);
   final JButton[] btns = {new JButton("Enter"), new JButton("Cancel")};
   for (int i = 0; i < btns.length; i++) {
     btns[i].addActionListener(
         new ActionListener() {
           public void actionPerformed(ActionEvent e) {
             dlg.setVisible(false);
           }
         });
   }
   Object[] prts = new Object[] {"Please input a password:"******"Invalid password, passwords must be " + PASSWORD_MIN + " characters long");
     System.exit(1);
   }
   return password;
 }
Beispiel #4
0
  public PasswordField(String label) {
    setLayout(new BorderLayout());
    m_label = new JLabel(label);

    if (label.length() > 0) {
      m_label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    }
    add(m_label, BorderLayout.WEST);

    m_password = new JPasswordField();
    m_password.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent e) {
            super.keyReleased(e);
            m_support.firePropertyChange("", null, null);
          }
        });
    m_password.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusLost(FocusEvent e) {
            super.focusLost(e);
            m_support.firePropertyChange("", null, null);
          }
        });

    add(m_password, BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  }
  private void setEnableStatusOfUseProxy(boolean enableStatus) {
    httpLabel.setEnabled(enableStatus);
    httpsLabel.setEnabled(enableStatus);
    ftpLabel.setEnabled(enableStatus);

    proxyAddressLabel.setEnabled(enableStatus);
    proxyPortLabel.setEnabled(enableStatus);
    proxyUserNameLabel.setEnabled(enableStatus);
    proxyPasswordLabel.setEnabled(enableStatus);
    httpProxyAddressTextField.setEnabled(enableStatus);
    httpProxyPortSpinner.setEnabled(enableStatus);
    httpProxyUserNameTextField.setEnabled(enableStatus);
    httpProxyPasswordField.setEnabled(enableStatus);

    httpsProxyAddressTextField.setEnabled(enableStatus);
    httpsProxyPortSpinner.setEnabled(enableStatus);
    httpsProxyUserNameTextField.setEnabled(enableStatus);
    httpsProxyPasswordField.setEnabled(enableStatus);

    ftpProxyAddressTextField.setEnabled(enableStatus);
    ftpProxyPortSpinner.setEnabled(enableStatus);
    ftpProxyUserNameTextField.setEnabled(enableStatus);
    ftpProxyPasswordField.setEnabled(enableStatus);

    socksLabel.setEnabled(!enableStatus);

    socksProxyAddressLabel.setEnabled(!enableStatus);
    socksProxyPortLabel.setEnabled(!enableStatus);
    socksProxyUserNameLabel.setEnabled(!enableStatus);
    socksProxyPasswordLabel.setEnabled(!enableStatus);
    socksProxyAddressTextField.setEnabled(!enableStatus);
    socksProxyPortSpinner.setEnabled(!enableStatus);
    socksProxyUserNameTextField.setEnabled(!enableStatus);
    socksProxyPasswordField.setEnabled(!enableStatus);
  }
  /**
   * Validates that inputted info is correct, resets password info in database resets textfields to
   * empty string ""
   *
   * @throws SQLException throws exception if connection could not be made
   */
  public void Validator() throws SQLException {
    update.setText("");
    setUser(UsersConnection.getInfo(username.getText(), emailf.getText(), 5));
    boolean validInfo = true;
    String emailinfo = new String(emailf.getText());
    if (emailinfo.equals("")) {
      emailWrong.setText("<html>*You must enter email to<br>update your password<html/>");
      validInfo = false;
    } else if (!emailinfo.equals(u.getEmail())) {
      System.out.println("here!");
      emailWrong.setText("*Wrong email");
      validInfo = false;
    } else emailWrong.setText("");

    String passinfo1 = new String(password1.getPassword());
    if (!passinfo1.equals("") && passinfo1.length() < 4) {
      pass1Wrong.setText("Password must at least 4 charactor");
      validInfo = false;
    } else pass1Wrong.setText("");
    String passinfo2 = new String(password2.getPassword());

    if (passinfo2.equals(passinfo1)) pass2Wrong.setText("");
    else {
      pass2Wrong.setText("*Password does not match");
      validInfo = false;
    }

    if (validInfo) {
      if (!passinfo1.equals("")) u.setPassword(passinfo1);
      init();
      update.setText("Your information is up-dated");
      emailWrong.setText("");
    }
  }
Beispiel #7
0
  loginframe() {
    Container c = getContentPane();
    c.setLayout(null);
    Color co1 = new Color(252, 251, 251);
    Color co2 = new Color(153, 153, 153);
    Color co3 = new Color(0, 0, 0);
    Font fo1 = new Font("Curlz MT", Font.BOLD, 35);
    Font fo2 = new Font("Tahoma", Font.BOLD, 14);
    Font fo3 = new Font("Tahoma", Font.PLAIN, 12);

    l1 = new JLabel("LOGIN");
    l1.setFont(fo1);
    c.add(l1);
    l1.setBounds(130, 30, 200, 30);
    l1.setForeground(co1);

    l2 = new JLabel("Username");
    c.add(l2);
    l2.setBounds(130, 100, 100, 30);
    l2.setForeground(co1);
    l2.setFont(fo2);

    l3 = new JLabel("Password");
    c.add(l3);
    l3.setBounds(130, 150, 100, 30);
    l3.setForeground(co1);
    l3.setFont(fo2);

    t1 = new JTextField();
    t1.setBounds(250, 100, 120, 25);
    c.add(t1);
    t1.setBackground(co2);
    t1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    t1.setForeground(co3);
    t1.setFont(fo3);

    p1 = new JPasswordField();
    p1.setBounds(250, 150, 120, 25);
    c.add(p1);
    p1.setBackground(co2);
    p1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

    b1 = new JButton("Login");
    b1.setBounds(140, 220, 70, 30);
    b1.addActionListener(this);
    c.add(b1);

    b2 = new JButton("Exit");
    b2.setBounds(270, 220, 70, 30);
    b2.addActionListener(this);
    c.add(b2);

    l4 = new JLabel("");
    c.add(l4);
    l4.setBounds(0, 0, 464, 409);
    l4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/loginpackage/locked2_1.jpg")));
  }
Beispiel #8
0
 public void setVisible(boolean bShow, String title) {
   if (bShow) {
     String strDir = "";
     String strFreq = "";
     String strTraynum = "";
     m_strHelpFile = getHelpFile(title);
     String strSampleName = getSampleName(title);
     String frameBounds = getFrameBounds(title);
     StringTokenizer tok = new QuotedStringTokenizer(title);
     if (tok.hasMoreTokens()) strDir = tok.nextToken();
     if (tok.hasMoreTokens()) strFreq = tok.nextToken();
     if (tok.hasMoreTokens()) strTraynum = tok.nextToken();
     else {
       try {
         Integer.parseInt(strDir);
         // if strdir is number, then strdir is empty, and the
         // strfreq is the number
         strTraynum = strFreq;
         strFreq = strDir;
         strDir = "";
       } catch (Exception e) {
       }
     }
     try {
       setTitle(gettitle(strFreq));
       m_lblSampleName.setText("3");
       boolean bVast = isVast(strTraynum);
       CardLayout layout = (CardLayout) m_pnlSampleName.getLayout();
       if (!bVast) {
         if (strSampleName == null) {
           strSampleName = getSampleName(strDir, strTraynum);
         }
         m_lblSampleName.setText(strSampleName);
         layout.show(m_pnlSampleName, OTHER);
       } else {
         m_strDir = strDir;
         setTrays();
         layout.show(m_pnlSampleName, VAST);
         m_trayTimer.start();
       }
       boolean bSample = bVast || !strSampleName.trim().equals("");
       m_pnlSampleName.setVisible(bSample);
       m_lblLogin.setForeground(getBackground());
       m_lblLogin.setVisible(false);
       m_passwordField.setText("");
       m_passwordField.setCaretPosition(0);
     } catch (Exception e) {
       Messages.writeStackTrace(e);
     }
     setBounds(frameBounds);
     ExpPanel exp = Util.getActiveView();
     if (exp != null) exp.waitLogin(true);
   }
   writePersistence();
   setVisible(bShow);
 }
  /** Clears all the data previously entered in the form. */
  public void clear() {
    usernameField.setText("");
    displayNameField.setText("");
    passField.setText("");
    retypePassField.setText("");
    emailField.setText("");
    errorPane.setText("");

    remove(errorPane);
  }
Beispiel #10
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;
  }
 /** resets all textfields to empty string "" */
 public void clean() {
   update.setText("");
   username.setText("");
   userWrong.setText("");
   emailf.setText("");
   password2.setText("");
   pass2Wrong.setText("");
   password1.setText("");
   pass1Wrong.setText("");
   emailWrong.setText("");
 }
Beispiel #12
0
 private void jbInit() throws Exception {
   this.getContentPane().setLayout(null);
   Bienvenue.setFont(new java.awt.Font("Garamond", 1, 24));
   Bienvenue.setForeground(SystemColor.textHighlight);
   Bienvenue.setRequestFocusEnabled(true);
   Bienvenue.setVerifyInputWhenFocusTarget(true);
   Bienvenue.setText("Bienvenue dans JChat");
   Bienvenue.setBounds(new Rectangle(125, 28, 305, 44));
   Pseudo_L.setFont(new java.awt.Font("Dialog", 1, 14));
   Pseudo_L.setText("Pseudonyme :");
   Pseudo_L.setBounds(new Rectangle(75, 94, 128, 28));
   nom.setText("");
   nom.setBounds(new Rectangle(229, 95, 108, 24));
   pwd.setText("");
   pwd.setBounds(new Rectangle(230, 135, 108, 25));
   pwd_L.setFont(new java.awt.Font("Dialog", 1, 14));
   pwd_L.setText("Mot de passe :");
   pwd_L.setBounds(new Rectangle(76, 133, 122, 31));
   gestionnaire_B gestionnaire = new gestionnaire_B();
   Connect.addActionListener(gestionnaire);
   Connect.setBackground(new Color(239, 240, 234));
   Connect.setBounds(new Rectangle(281, 251, 142, 30));
   Connect.setText("Connexion");
   Connect.setIcon(new ImageIcon(image_c));
   Annuler.addActionListener(gestionnaire);
   Annuler.setBackground(new Color(239, 240, 234));
   Annuler.setBounds(new Rectangle(104, 252, 140, 29));
   Annuler.setText("Annuler");
   Annuler.setIcon(new ImageIcon(image_d));
   this.getContentPane().setBackground(new Color(239, 240, 234));
   this.setForeground(new Color(239, 240, 234));
   this.setTitle("Interface de connexion des clients au serveur de chat");
   jLabel1.setFont(new java.awt.Font("Dialog", 1, 14));
   jLabel1.setText("Adresse du serveur :");
   jLabel1.setBounds(new Rectangle(75, 176, 156, 26));
   jTextField1.setBounds(new Rectangle(230, 176, 108, 25));
   Icon siegle = new ImageIcon(image);
   siegle_L = new JLabel("", siegle, SwingConstants.LEFT);
   siegle_L.setBounds(new Rectangle(0, 1, 76, 105));
   this.getContentPane().add(jLabel1, null);
   this.getContentPane().add(pwd_L, null);
   this.getContentPane().add(Pseudo_L, null);
   this.getContentPane().add(jTextField1, null);
   this.getContentPane().add(nom, null);
   this.getContentPane().add(pwd, null);
   this.getContentPane().add(Bienvenue, null);
   this.getContentPane().add(Connect, null);
   this.getContentPane().add(Annuler, null);
   this.getContentPane().add(siegle_L, null);
   this.setSize(new Dimension(439, 321));
   this.setResizable(false);
   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   this.setVisible(true);
 }
  /**
   * Initializes all of the text fields to empty string ""
   *
   * @throws SQLException throws exception if connection could not be made
   */
  void init() throws SQLException {
    if (u != null) {
      userWrong.setText("");
      pass1Wrong.setText("");
      pass2Wrong.setText("");
      emailWrong.setText("");

      emailf.setText("");
      password1.setText("");
      password2.setText("");
    }
  }
Beispiel #14
0
  private void initComponents() {

    btLogin.setFocusable(false); // Fókusz letiltása
    btSettings.setFocusable(false); // Fókusz letiltása

    btLogin.setBackground(Color.lightGray); // A "bejelentkezés" gomb háttérszínének beállítása
    btSettings.setBackground(
        pnLogin.getBackground()); // A "Beállítások" gomb háttérszínének beállítása

    tfUsername.setPreferredSize(new Dimension(120, 25)); // Szövegmező átméretezése
    pfPassword.setPreferredSize(new Dimension(120, 25)); // Jelszómező átméretezése

    tfUsername.addKeyListener(btEnabler); // A figyelő hozzáadása a felhasználónév mezőhőz
    pfPassword.addKeyListener(btEnabler); // A figyelő hozzáadása a jelszó mezőhőz
  }
Beispiel #15
0
  private void jbInit() throws Exception {
    // this.setResizable(false);
    this.setSize(ancho, alto);
    this.setLocation(0, 0);

    // this.setUndecorated(true);
    // this.getContentPane().setLayout(null);

    // limites de componentes
    labelFondo.setBounds(
        new Rectangle((int) (ancho / 5), 2 * (alto / 6), (int) (ancho / 1.5), alto / 4));
    botonCancelar.setBounds(
        new Rectangle(
            (int) (2.9 * (ancho / 5)), (int) (2 * (alto / 4)), (int) (ancho / 10.2), alto / 25));
    botonCancelar.setBorder(null);
    // botonAceptar.setBounds(new Rectangle(0, 0, 100, 30));
    botonAceptar.setBounds(
        new Rectangle(
            (int) (2.15 * (ancho / 5)), (int) (2 * (alto / 4)), (int) (ancho / 10.2), alto / 25));
    botonAceptar.setBorder(null);
    textNombre.setFont(new java.awt.Font("Serif", 3, 15));
    textNombre.setBounds(
        new Rectangle((int) (2.5 * (ancho / 5)), (int) (1.5 * (alto / 4)), ancho / 5, alto / 25));
    textNombre.addKeyListener(new PanelNick_textNombre_keyAdapter(this));

    textContra.setFont(new java.awt.Font("Serif", 3, 15));
    textContra.setBounds(
        new Rectangle(
            (int) (2.9 * (ancho / 5)), (int) (1.65 * (alto / 4)) + 20, ancho / 8, alto / 25));

    // imagenes de componentes
    labelFondo.setIcon(new ImageIcon("../imagenes/introduceNick.jpg"));
    botonCancelar.setIcon(new ImageIcon("../imagenes/botoncancelar.jpg"));
    botonCancelar.addMouseListener(new PanelNick_botonCancelar_mouseAdapter(this));
    botonAceptar.setIcon(new ImageIcon("../imagenes/botonaceptar.jpg"));
    botonAceptar.addMouseListener(new PanelNick_botonAceptar_mouseAdapter(this));

    // agregar componentes al panel
    this.add(textContra, null);
    this.add(botonCancelar, null);
    this.add(botonAceptar, null);
    this.add(textNombre, null);
    this.add(labelFondo, null);

    // acciones de botones
    botonAceptar.addActionListener(new PanelNick_botonAceptar_actionAdapter(this));
    botonCancelar.addActionListener(new PanelNick_botonCancelar_actionAdapter(this));
  }
Beispiel #16
0
  public LoginP() {
    super("LOGIN");
    l1 = new JLabel("UserName");
    l2 = new JLabel("Password");
    t1 = new JTextField();
    t2 = new JPasswordField();
    d = new JTextField("r");
    b1 = new JButton("Let me in !!");

    setBounds(300, 250, 380, 240);

    l1.setBounds(20, 50, 100, 30);
    l2.setBounds(20, 90, 100, 30);
    t1.setBounds(120, 50, 150, 30);
    t1.setText("Administrator");
    t2.setBounds(120, 90, 150, 30);
    b1.setBounds(180, 130, 150, 25);
    add(l1);
    add(l2);
    add(t1);
    add(t2);
    add(b1);

    setLayout(null);
    setVisible(true);

    b1.addActionListener(this);

    setDefaultCloseOperation(EXIT_ON_CLOSE);
  }
  @Override
  public void apply(@NotNull HttpConfigurable settings) {
    if (!isValid()) {
      return;
    }

    if (isModified(settings)) {
      settings.AUTHENTICATION_CANCELLED = false;
    }

    settings.USE_PROXY_PAC = myAutoDetectProxyRb.isSelected();
    settings.USE_PAC_URL = myPacUrlCheckBox.isSelected();
    settings.PAC_URL = getText(myPacUrlTextField);
    settings.USE_HTTP_PROXY = myUseHTTPProxyRb.isSelected();
    settings.PROXY_TYPE_IS_SOCKS = mySocks.isSelected();
    settings.PROXY_AUTHENTICATION = myProxyAuthCheckBox.isSelected();
    settings.KEEP_PROXY_PASSWORD = myRememberProxyPasswordCheckBox.isSelected();

    settings.setProxyLogin(getText(myProxyLoginTextField));
    settings.setPlainProxyPassword(new String(myProxyPasswordTextField.getPassword()));
    settings.PROXY_EXCEPTIONS = StringUtil.nullize(myProxyExceptions.getText(), true);

    settings.PROXY_PORT = myProxyPortTextField.getNumber();
    settings.PROXY_HOST = getText(myProxyHostTextField);
  }
  private boolean isValid() {
    if (myUseHTTPProxyRb.isSelected()) {
      String host = getText(myProxyHostTextField);
      if (host == null) {
        return false;
      }

      try {
        HostAndPort parsedHost = HostAndPort.fromString(host);
        if (parsedHost.hasPort()) {
          return false;
        }
        host = parsedHost.getHostText();

        try {
          InetAddresses.forString(host);
          return true;
        } catch (IllegalArgumentException e) {
          // it is not an IPv4 or IPv6 literal
        }

        InternetDomainName.from(host);
      } catch (IllegalArgumentException e) {
        return false;
      }

      if (myProxyAuthCheckBox.isSelected()) {
        return !StringUtil.isEmptyOrSpaces(myProxyLoginTextField.getText())
            && myProxyPasswordTextField.getPassword().length > 0;
      }
    }
    return true;
  }
  @Override
  public void reset(@NotNull HttpConfigurable settings) {
    myNoProxyRb.setSelected(true); // default
    myAutoDetectProxyRb.setSelected(settings.USE_PROXY_PAC);
    myPacUrlCheckBox.setSelected(settings.USE_PAC_URL);
    myPacUrlTextField.setText(settings.PAC_URL);
    myUseHTTPProxyRb.setSelected(settings.USE_HTTP_PROXY);
    myProxyAuthCheckBox.setSelected(settings.PROXY_AUTHENTICATION);

    enableProxy(settings.USE_HTTP_PROXY);

    myProxyLoginTextField.setText(settings.getProxyLogin());
    myProxyPasswordTextField.setText(settings.getPlainProxyPassword());

    myProxyPortTextField.setNumber(settings.PROXY_PORT);
    myProxyHostTextField.setText(settings.PROXY_HOST);
    myProxyExceptions.setText(StringUtil.notNullize(settings.PROXY_EXCEPTIONS));

    myRememberProxyPasswordCheckBox.setSelected(settings.KEEP_PROXY_PASSWORD);
    mySocks.setSelected(settings.PROXY_TYPE_IS_SOCKS);
    myHTTP.setSelected(!settings.PROXY_TYPE_IS_SOCKS);

    boolean showError = !StringUtil.isEmptyOrSpaces(settings.LAST_ERROR);
    myErrorLabel.setVisible(showError);
    myErrorLabel.setText(showError ? errorText(settings.LAST_ERROR) : null);

    final String oldStyleText =
        CommonProxy.getMessageFromProps(CommonProxy.getOldStyleProperties());
    myOtherWarning.setVisible(oldStyleText != null);
    if (oldStyleText != null) {
      myOtherWarning.setText(oldStyleText);
      myOtherWarning.setIcon(Messages.getWarningIcon());
    }
  }
  public void reset() {
    myNoProxyRb.setSelected(true); // default
    HttpConfigurable httpConfigurable = myHttpConfigurable;
    myAutoDetectProxyRb.setSelected(httpConfigurable.USE_PROXY_PAC);
    myPacUrlCheckBox.setSelected(httpConfigurable.USE_PAC_URL);
    myPacUrlTextField.setText(httpConfigurable.PAC_URL);
    myUseHTTPProxyRb.setSelected(httpConfigurable.USE_HTTP_PROXY);
    myProxyAuthCheckBox.setSelected(httpConfigurable.PROXY_AUTHENTICATION);

    enableProxy(httpConfigurable.USE_HTTP_PROXY);

    myProxyLoginTextField.setText(httpConfigurable.PROXY_LOGIN);
    myProxyPasswordTextField.setText(httpConfigurable.getPlainProxyPassword());

    myProxyPortTextField.setText(Integer.toString(httpConfigurable.PROXY_PORT));
    myProxyHostTextField.setText(httpConfigurable.PROXY_HOST);
    myProxyExceptions.setText(httpConfigurable.PROXY_EXCEPTIONS);

    myRememberProxyPasswordCheckBox.setSelected(httpConfigurable.KEEP_PROXY_PASSWORD);
    mySocks.setSelected(httpConfigurable.PROXY_TYPE_IS_SOCKS);
    myHTTP.setSelected(!httpConfigurable.PROXY_TYPE_IS_SOCKS);

    final boolean showError = !StringUtil.isEmptyOrSpaces(httpConfigurable.LAST_ERROR);
    myErrorLabel.setVisible(showError);
    myErrorLabel.setText(showError ? errorText(httpConfigurable.LAST_ERROR) : "");

    final String oldStyleText =
        CommonProxy.getMessageFromProps(CommonProxy.getOldStyleProperties());
    myOtherWarning.setVisible(oldStyleText != null);
    if (oldStyleText != null) {
      myOtherWarning.setText(oldStyleText);
      myOtherWarning.setUI(new MultiLineLabelUI());
      myOtherWarning.setIcon(Messages.getWarningIcon());
    }
  }
  public boolean isModified() {
    boolean isModified = false;
    HttpConfigurable httpConfigurable = myHttpConfigurable;
    if (!Comparing.equal(myProxyExceptions.getText().trim(), httpConfigurable.PROXY_EXCEPTIONS))
      return true;
    isModified |= httpConfigurable.USE_PROXY_PAC != myAutoDetectProxyRb.isSelected();
    isModified |= httpConfigurable.USE_PAC_URL != myPacUrlCheckBox.isSelected();
    isModified |= !Comparing.strEqual(httpConfigurable.PAC_URL, myPacUrlTextField.getText());
    isModified |= httpConfigurable.USE_HTTP_PROXY != myUseHTTPProxyRb.isSelected();
    isModified |= httpConfigurable.PROXY_AUTHENTICATION != myProxyAuthCheckBox.isSelected();
    isModified |=
        httpConfigurable.KEEP_PROXY_PASSWORD != myRememberProxyPasswordCheckBox.isSelected();
    isModified |= httpConfigurable.PROXY_TYPE_IS_SOCKS != mySocks.isSelected();

    isModified |=
        !Comparing.strEqual(httpConfigurable.PROXY_LOGIN, myProxyLoginTextField.getText());
    isModified |=
        !Comparing.strEqual(
            httpConfigurable.getPlainProxyPassword(),
            new String(myProxyPasswordTextField.getPassword()));

    try {
      isModified |=
          httpConfigurable.PROXY_PORT != Integer.valueOf(myProxyPortTextField.getText()).intValue();
    } catch (NumberFormatException e) {
      isModified = true;
    }
    isModified |= !Comparing.strEqual(httpConfigurable.PROXY_HOST, myProxyHostTextField.getText());
    return isModified;
  }
Beispiel #22
0
  public PasswordDialog(final JFrame owner) {
    super(owner, "Login", true);
    setSize(280, 150);
    user = new JTextField(10);
    user.addActionListener(this);
    password = new JPasswordField(10);
    password.addActionListener(this);
    JPanel center = new JPanel();
    center.setLayout(new GridLayout(3, 2));
    center.add(new JLabel("Enter UserName:"******"Enter Password: "******"Submit");
    submitButton.setActionCommand("SUBMIT");
    submitButton.addActionListener(this);

    JButton helpButton = new JButton("Help");
    south.add(submitButton);
    south.add(helpButton);
    helpButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent aEvent) {
            JOptionPane.showMessageDialog(
                owner,
                "Your username and password are the same as those\n"
                    + "you use to access your O'Reilly School of Technology courses. \n");
          }
        });
    Container contentPane = getContentPane();
    contentPane.add(center, BorderLayout.CENTER);
    contentPane.add(south, BorderLayout.SOUTH);
  }
 /**
  * Based on the mode that is set by constructors and depending on the type of the mode value a
  * different value is returned.
  *
  * <p>The type of mode values are <code>int</code>, <code>double</code>, <code>String</code> and
  * <code>Pass</code>
  *
  * <p>Returns <code>null</code> if mode type does not match.
  */
 public Object getValue() {
   if (mode == INT) return (int) Integer.valueOf(inputfield.getText());
   else if (mode == DOUBLE) return (double) Double.valueOf(inputfield.getText());
   else if (mode == STRING) return (String) inputfield.getText();
   else if (mode == PASS) return (char[]) passfield.getPassword();
   else return null;
 }
 private void onRegister(Frame parent) {
   String username = loginField.getText();
   String password = String.valueOf(passwordField.getPassword());
   dispose();
   RegisterDialog registerDialog = new RegisterDialog(username, password, parent);
   registerDialog.setVisible(true);
 }
  public void login() {
    boolean found = false;

    for (UserProfile up : menu.getMain().getUserProfiles()) {
      if (up.getUsername().equals(username.getText())) {
        char[] pwd = password.getPassword();
        String pwdAsString = "";

        for (char c : pwd) {
          pwdAsString += c;
        }

        if (up.getPassword() == pwdAsString.hashCode()) {
          clearFields();

          menu.getMain().setCurrentUser(up);
          menu.getMain().setUserHistory(up.getUserHistory());
          Spreadsheet.fileSelectEditor.setFtpManager(up.getFtpManager());
          menu.changeView(menu.getMainMenuGUI());
          found = true;

          break;
        }
      }
    }

    if (!found) {
      status.setText("<html><b>Error: </b> Username or password incorrect! </html>");
    }
  }
Beispiel #26
0
 // These is some wierd problem such that sometimes, the vnmrj command
 // area gets the focus and these items in the login box do not get
 // the focus.  Even clicking in these items does not bring focus to
 // them.  Issuing requestFocus() does not bring focus to them.
 // I can however, determing if either the operator entry box or
 // the password box has focus and if neither does, I can unshow and
 // reshow the panel and that fixes the focus.  So, I have added this
 // to the mouseClicked action.  If neither has focus, it will
 // take focus with setVisible false then true.
 public void mouseClicked(MouseEvent e) {
   boolean pfocus = m_passwordField.hasFocus();
   boolean ofocus = comboTextField.hasFocus();
   if (!pfocus && !ofocus) {
     setVisible(false);
     setVisible(true);
   }
 }
Beispiel #27
0
  public static void LoginDialog() {

    JLabel title = new JLabel("Login Username and Password");
    JTextField username = new JTextField();
    JPasswordField password = new JPasswordField();
    final JComponent[] inputs =
        new JComponent[] {
          title, new JLabel("Username"), username, new JLabel("Password"), password
        };
    JOptionPane.showMessageDialog(null, inputs, "Login", JOptionPane.PLAIN_MESSAGE);

    userName = username.getText();
    passWord = new String(password.getPassword());
    if (!getLogin()) {
      LoginDialog();
    }
  }
  private void enableProxyAuthentication(boolean enabled) {
    myProxyPasswordLabel.setEnabled(enabled);
    myProxyLoginLabel.setEnabled(enabled);

    myProxyLoginTextField.setEnabled(enabled);
    myProxyPasswordTextField.setEnabled(enabled);

    myRememberProxyPasswordCheckBox.setEnabled(enabled);
  }
  public PreferencesProxyDTO getPreferencesProxyDTO() {
    String proxySettingType = proxySettingGroup.getSelection().getActionCommand();
    switch (proxySettingType) {
      case "noProxy":
        preferencesProxyDTO.setProxySettingType(0);
        break;
      case "systemProxy":
        preferencesProxyDTO.setProxySettingType(1);
        break;
      case "manualProxy":
        preferencesProxyDTO.setProxySettingType(2);
    }

    if (useProxyRadioButton.isSelected()) preferencesProxyDTO.setUseProxyNotSocks(true);
    else preferencesProxyDTO.setUseProxyNotSocks(false);

    // for http
    preferencesProxyDTO.setHttpProxyAddress(httpProxyAddressTextField.getText());
    preferencesProxyDTO.setHttpProxyPort((Integer) httpProxyPortSpinner.getValue());
    preferencesProxyDTO.setHttpProxyUserName(httpProxyUserNameTextField.getText());
    preferencesProxyDTO.setHttpProxyPassword(new String(httpProxyPasswordField.getPassword()));

    // for https
    preferencesProxyDTO.setHttpsProxyAddress(httpsProxyAddressTextField.getText());
    preferencesProxyDTO.setHttpsProxyPort((Integer) httpsProxyPortSpinner.getValue());
    preferencesProxyDTO.setHttpsProxyUserName(httpsProxyUserNameTextField.getText());
    preferencesProxyDTO.setHttpsProxyPassword(new String(httpsProxyPasswordField.getPassword()));

    // for ftp
    preferencesProxyDTO.setFtpProxyAddress(ftpProxyAddressTextField.getText());
    preferencesProxyDTO.setFtpProxyPort((Integer) ftpProxyPortSpinner.getValue());
    preferencesProxyDTO.setFtpProxyUserName(ftpProxyUserNameTextField.getText());
    preferencesProxyDTO.setFtpProxyPassword(new String(ftpProxyPasswordField.getPassword()));

    // for ftp
    preferencesProxyDTO.setSocksProxyAddress(socksProxyAddressTextField.getText());
    preferencesProxyDTO.setSocksProxyPort((Integer) socksProxyPortSpinner.getValue());
    preferencesProxyDTO.setSocksProxyUserName(socksProxyUserNameTextField.getText());
    preferencesProxyDTO.setSocksProxyPassword(new String(socksProxyPasswordField.getPassword()));

    return preferencesProxyDTO;
  }
Beispiel #30
0
  public AccesoSistema() {

    super("Ingreso Al Sistema");
    setSize(400, 200); // el tamaño de la venta
    setLocationRelativeTo(null); // es para que la pantalla aparezaca en el centro
    setLayout(null);
    setVisible(true); // para mostrar la ventana

    // esta parte de arriba es el constructor : es el que le premite crear componentes

    lblimagen.setIcon(getClass().getResource("/Imagenes/Escudo.png"));
    lblimagen.setBounds(270, 10, 120, 140);
    this.add(lblimagen);
    lblusuario = new JLabel("Usuario: ");
    lblclave = new JLabel("Contraseña: ");
    txtusuario = new JTextField("");
    txtclave = new JPasswordField("");
    btningresar = new JButton("Ingresar");
    txtusuario.addActionListener(this);
    txtclave.addActionListener(this);
    btningresar.addActionListener(this); // Ponemos A Escuchar El Boton
    btnsalir = new JButton("Salir");
    btnsalir.addActionListener(this);
    lblusuario.setBounds(20, 20, 80, 25);
    lblclave.setBounds(20, 60, 80, 25);
    txtusuario.setBounds(130, 20, 120, 25);
    txtclave.setBounds(130, 60, 120, 25);
    btningresar.setBounds(20, 100, 120, 25);
    btnsalir.setBounds(150, 100, 120, 25);
    lblusuario.setForeground(new Color(0, 0, 0));
    // lblusuario.setBorder(BorderFactory.createLineBorder(Color.yellow, WIDTH));//sirve para
    // mostrar el tamaño del lbl
    txtusuario.setBackground(Color.WHITE); // este es para darle color a la caja de texto
    txtusuario.setToolTipText("Ingrese Su Usuario"); // sirve para mostrar mensajes emergentes
    this.add(lblusuario);
    this.add(lblclave);
    this.add(txtusuario);
    this.add(txtclave);
    this.add(btningresar);
    this.add(btnsalir);
    this.repaint();
  }