Ejemplo n.º 1
0
  private boolean prepareX509Infrastructure() {
    if (caKeystorePassword == null) {
      JPasswordField pass = new JPasswordField(10);
      pass.setText(caKeystorePassword);
      pass.addAncestorListener(new RequestFocusListener());
      JPanel panel = new JPanel(new BorderLayout());
      panel.add(new JLabel(Translation.get("gb.enterKeystorePassword")), BorderLayout.NORTH);
      panel.add(pass, BorderLayout.CENTER);
      int result =
          JOptionPane.showConfirmDialog(
              GitblitAuthority.this,
              panel,
              Translation.get("gb.password"),
              JOptionPane.OK_CANCEL_OPTION);
      if (result == JOptionPane.OK_OPTION) {
        caKeystorePassword = new String(pass.getPassword());
      } else {
        return false;
      }
    }

    X509Metadata metadata = new X509Metadata("localhost", caKeystorePassword);
    setMetadataDefaults(metadata);
    metadata.notAfter = new Date(System.currentTimeMillis() + 10 * TimeUtils.ONEYEAR);
    X509Utils.prepareX509Infrastructure(metadata, folder, this);
    return true;
  }
Ejemplo n.º 2
0
  /**
   * Display input dialog for user to enter password
   *
   * @param parent parent component
   * @param title what to show on the dialog box title
   * @param message what to show to user.
   * @param fontsize how big should the font be
   * @return
   */
  public static String showInputPassword(
      Component parent, String title, String message, int fontsize) {
    JPanel panel = new JPanel();
    JLabel label = new JLabel(rb.getString("Message.entersudopassword") + "\r\n");
    label.setFont(new Font(label.getFont().getName(), Font.PLAIN, fontsize));
    JPasswordField pass = new JPasswordField(10);
    panel.add(label);
    panel.add(pass);
    String[] options = new String[] {"OK", "Cancel"};

    MessageDialogFactory.showOptionDialog(
        parent,
        panel,
        "Admin Right Required",
        JOptionPane.NO_OPTION,
        JOptionPane.PLAIN_MESSAGE,
        null,
        options,
        options[0]);
    char[] passarr = pass.getPassword();
    if (passarr == null) {
      return "";
    }
    return new String(passarr);
  }
Ejemplo n.º 3
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));
  }
  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;
  }
Ejemplo n.º 5
0
 private void loadConfig() {
   // check for file
   this.fileCheck = new File("cHamster.config");
   this.configFile = new Properties();
   // check for existing config
   if (fileCheck.exists()) {
     try {
       this.configFile.load(new FileReader(fileCheck));
     } catch (FileNotFoundException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (IOException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
     // Load configuration
     userField.setText(this.configFile.getProperty("username"));
     passwordField.setText(this.configFile.getProperty("password"));
     serverField.setText(this.configFile.getProperty("server"));
     portField.setText(this.configFile.getProperty("port"));
     resField.setText(this.configFile.getProperty("resolution"));
     fpsField.setText(this.configFile.getProperty("fps"));
   } else {
     // Create new default configuration and store it
     userField.setText("big");
     passwordField.setText("brother");
     serverField.setText("www.example.com");
     portField.setText("6666");
     resField.setText("320x240");
     fpsField.setText("5");
     this.storeConfig();
     // (Default values allready in the fields)
   }
 }
  private void addComponents() {
    JPanel panel1 = new JPanel();
    add(panel1);

    JLabel label1 = new JLabel("Ingrese su contraseña actual");
    panel1.add(label1);
    panel1.add(oldPassword);

    JLabel label2 = new JLabel("Escriba su nueva contraseña");
    panel1.add(label2);
    panel1.add(newPassword);

    JLabel label3 = new JLabel("Reescriba su nueva contraseña");
    panel1.add(label3);
    panel1.add(conPassword);

    oldPassword.setAction(am.getChangePassword(this));
    newPassword.setAction(am.getChangePassword(this));
    conPassword.setAction(am.getChangePassword(this));

    JButton passButton = new JButton();
    passButton.setAction(am.getChangePassword(this));
    panel1.add(passButton);

    setSize(270, 210);
    setLocationRelativeTo(null);
    setResizable(false);
    setVisible(true);
  }
Ejemplo n.º 7
0
  @SuppressWarnings("empty-statement")
  private String getPassWd(boolean first) {
    String passWd = "";
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    if (first) panel.add(new JLabel("Enter Password\n\n"));
    else panel.add(new JLabel("Re-enter Password\n\n"));
    final JPasswordField passwordField =
        new JPasswordField(10); // box to take passwords from the user
    panel.add(passwordField);
    JOptionPane pane =
        new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION) {
          private static final long serialVersionUID = 1L;

          @Override
          public void selectInitialValue() {
            passwordField.requestFocusInWindow();
          }
        };
    pane.createDialog(null, "Enter Password").setVisible(true);
    passWd =
        passwordField.getPassword().length == 0 ? null : new String(passwordField.getPassword());
    passwordField.setText("");
    return passWd;
  }
  public Inscription() {
    labelName = new JLabel(" Nom : ");
    labelFirstName = new JLabel(" Prénom : ");
    labelLogin = new JLabel(" Login : "******" Mot de passe : ");
    labelPassword2 = new JLabel(" Confirmation mot de passe : ");
    labelAddress = new JLabel("\n Adresse : ");

    name = new JTextField(5);
    password = new JPasswordField(8);

    password.setEchoChar('*');
    password2 = new JPasswordField(8);

    password2.setEchoChar('*');

    firstName = new JTextField(5);
    address = new JTextField(30);

    this.add(labelPassword);
    this.add(password);
    this.add(labelPassword2);
    this.add(password2);

    this.add(labelName);
    this.add(name);
    this.add(labelFirstName);
    this.add(firstName);
    this.add(labelAddress);
    this.add(address);
  }
Ejemplo n.º 9
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;
    }
  }
  /**
   * 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("");
    }
  }
Ejemplo n.º 11
0
  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);
  }
Ejemplo n.º 12
0
 private static void showDialog(String[] login) {
   JTextField uf = new JTextField(20);
   uf.setText(login[0]);
   JPasswordField pf = new JPasswordField(20);
   JPanel p = new JPanel(new GridBagLayout());
   GridBagConstraints gbc = new GridBagConstraints();
   gbc.anchor = GridBagConstraints.FIRST_LINE_START;
   gbc.insets.left = 5;
   gbc.insets.bottom = 5;
   gbc.gridx = 0;
   gbc.gridy = 0;
   p.add(new JLabel("User"), gbc);
   gbc.gridx = 1;
   gbc.gridy = 0;
   p.add(uf, gbc);
   gbc.gridx = 0;
   gbc.gridy = 1;
   p.add(new JLabel("Password"), gbc);
   gbc.gridx = 1;
   gbc.gridy = 1;
   p.add(pf, gbc);
   JOptionPane op = new JOptionPane(p);
   op.setOptions(new String[] {"OK", "Cancel"});
   JDialog dlg = op.createDialog(null, "Login");
   dlg.pack();
   int i = SupportUI.show(dlg, op);
   if (i != 0) {
     System.exit(0);
   }
   login[0] = uf.getText().trim();
   login[1] = new String(pf.getPassword());
 }
Ejemplo n.º 13
0
  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);
    }
  }
Ejemplo n.º 14
0
 // Check if OK should be enabled
 // Called on:
 //      -- change in text field
 //      -- change in check box selection
 //      -- change in team combo selection
 // Required:
 //      -- userName
 //      -- at least one check box
 //      -- password, if this is an Add, but not if Edit
 // Not required: TBD: ???
 //      -- First and Last Name
 //      -- Team
 private void checkOkSetEnabled() {
   char[] pchars = password.getPassword();
   char[] cchars = confirmPassword.getPassword();
   if (!userName.getText().equals("")
       && (unitizeCheckBox.isSelected()
           || uqcCheckBox.isSelected()
           || codingCheckBox.isSelected()
           || codingqcCheckBox.isSelected()
           || listingCheckBox.isSelected()
           || tallyCheckBox.isSelected()
           || qaCheckBox.isSelected()
           || tlCheckBox.isSelected()
           || adminCheckBox.isSelected())
       && (usersId != 0 || pchars.length != 0)
       && (pchars.length == 0 || cchars.length != 0)) {
     okButton.setEnabled(true);
   } else {
     okButton.setEnabled(false);
   }
   if (pchars.length == 0) {
     confirmPassword.setEditable(false);
   } else {
     confirmPassword.setEditable(true);
   }
   Arrays.fill(pchars, '#');
   Arrays.fill(cchars, '#');
 }
Ejemplo n.º 15
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, "服务器未开启!");
     }
   }
 }
Ejemplo n.º 16
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;
 }
Ejemplo n.º 17
0
  public static void init(JPasswordField fpasswd) {
    try {
      String resource = "artemis_sqlmap/chado_iBatis_config.xml";
      Reader reader = Resources.getResourceAsReader(resource);

      Properties properties = null;
      if (System.getProperty("chado") != null) {
        String url = System.getProperty("chado");
        int index = url.indexOf("?");
        int index2 = url.indexOf("user="******"://");
        if (index3 < 0) index3 = 0;
        else index3 = index3 + 3;

        properties.put("chado", url.substring(index3, index));

        if (index2 < 0) properties.put("username", url.substring(index + 1));
        else properties.put("username", url.substring(index2 + 5));

        if (fpasswd != null && fpasswd.getPassword().length > 0)
          properties.put("password", new String(fpasswd.getPassword()));
      }

      sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader, properties);
    } catch (Exception e) {
      // If you get an error at this point, it doesnt matter what it was.  It is going to be
      // unrecoverable and we will want the app to blow up hard so we are aware of the
      // problem.  You should always log such errors and re-throw them in such a way that
      // you can be made immediately aware of the problem.
      e.printStackTrace();
      throw new RuntimeException("Error initializing DbSqlConfig class.  Cause: " + e);
    }
  }
Ejemplo n.º 18
0
  /** Adds listeners to the UI components. */
  private void initListeners() {
    user.getDocument().addDocumentListener(this);
    pass.getDocument().addDocumentListener(this);
    login.addActionListener(this);
    user.addActionListener(this);
    pass.addActionListener(this);
    cancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            quit();
          }
        });
    configButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            config();
          }
        });
    encryptionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            encrypt();
          }
        };
    encryptedButton.addActionListener(encryptionListener);
    addWindowListener(
        new WindowAdapter() {
          public void windowOpened(WindowEvent e) {
            requestFocusOnField();
          }
        });
    user.addMouseListener(
        new MouseAdapter() {

          /**
           * Fires a property to move the window to the front.
           *
           * @see MouseListener#mouseClicked(MouseEvent)
           */
          public void mouseClicked(MouseEvent e) {
            firePropertyChange(TO_FRONT_PROPERTY, Boolean.valueOf(false), Boolean.valueOf(true));
            user.requestFocus();
            // if (user.getText() != null)
            //	user.selectAll();
          }
        });
    pass.addMouseListener(
        new MouseAdapter() {

          /**
           * Fires a property to move the window to the front.
           *
           * @see MouseListener#mouseClicked(MouseEvent)
           */
          public void mouseClicked(MouseEvent e) {
            firePropertyChange(TO_FRONT_PROPERTY, Boolean.valueOf(false), Boolean.valueOf(true));
            // requestFocusOnField();
          }
        });
  }
Ejemplo n.º 19
0
  public static char[] showPasswordDialog(Component parent, String titre) {
    final JPasswordField jpf = new JPasswordField();
    JOptionPane jop =
        new JOptionPane(jpf, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
    // FIXME: label
    JDialog dialog = jop.createDialog(parent, titre);
    dialog.addComponentListener(
        new ComponentAdapter() {

          public void componentShown(ComponentEvent e) {
            jpf.requestFocusInWindow();
          }
        });
    dialog.setVisible(true);
    if (jop.getValue() == null) {
      return null;
    }
    int result = (Integer) jop.getValue();
    dialog.dispose();
    char[] password = null;
    if (result == JOptionPane.OK_OPTION) {
      password = jpf.getPassword();
    } else {
      return null;
    }
    return password;
  }
 public void actionPerformed(ActionEvent e) {
   if (e.getActionCommand().equals(CANCEL)) this.dispose();
   if (e.getActionCommand().equals(OK)) {
     // Check password
     try {
       UserAccountDao uad2 = new UserAccountDaoImpl();
       user = uad2.loginAuthorization(this.getUsername(), this.getPassword());
       System.out.println("the user's email:" + user.getEmail() + "admin?:" + getIsAdmin());
       model.setMyAccount(user);
       successfulLogin();
       this.dispose();
     } catch (PwdIncorrectException pie) {
       // pop up a window said incorrect password
       JOptionPane.showMessageDialog(
           null, "Incorrect password. Try again.", "Error Message", JOptionPane.ERROR_MESSAGE);
       passwordField.selectAll();
       passwordField.setText("");
       userName.setText("");
     } catch (UserAccountNotFoundException uanfe) {
       // pop up a window said cannot find the user account
       JOptionPane.showMessageDialog(
           null, "User not exist. Try again.", "Error Message", JOptionPane.ERROR_MESSAGE);
       passwordField.selectAll();
       passwordField.setText("");
       userName.setText("");
     }
   }
 }
Ejemplo n.º 21
0
 private void componentes() {
   JLabel lblLogin = new JLabel("Login");
   lblLogin.setFont(new Font("Tahoma", Font.PLAIN, 13));
   lblLogin.setBounds(10, 11, 46, 14);
   getContentPane().add(lblLogin);
   jLogin = new JTextField();
   jLogin.setBounds(66, 9, 128, 20);
   getContentPane().add(jLogin);
   jLogin.setColumns(10);
   JLabel lblSenha = new JLabel("Senha");
   lblSenha.setFont(new Font("Tahoma", Font.PLAIN, 13));
   lblSenha.setBounds(10, 36, 46, 14);
   getContentPane().add(lblSenha);
   jSenha = new JPasswordField();
   jSenha.setBounds(66, 40, 128, 20);
   getContentPane().add(jSenha);
   jSenha.setColumns(10);
   btnEntrar = new JButton("Entrar");
   btnEntrar.setBounds(204, 8, 128, 23);
   getContentPane().add(btnEntrar);
   btnNovoCadastro = new JButton("Novo Cadastro");
   btnNovoCadastro.setBounds(204, 39, 128, 23);
   getContentPane().add(btnNovoCadastro);
   btnEsqueciASenha = new JButton("Esqueci a Senha");
   btnEsqueciASenha.setBounds(66, 71, 128, 23);
   getContentPane().add(btnEsqueciASenha);
 }
Ejemplo n.º 22
0
 // efface le texte
 public void deleteEntry() {
   name.setText("");
   firstName.setText("");
   address.setText("");
   password.setText("");
   password2.setText("");
   login.setText("");
 }
Ejemplo n.º 23
0
  /** Create the panel for Welcome. */
  public Welcome() {
    setBackground(Color.YELLOW);
    setSize(648, 445);
    setLayout(null);

    // Creating labels, buttons, textFields and adding attributes

    JLabel snakeIcon = new JLabel("");
    snakeIcon.setBounds(400, 142, 242, 261);
    Image img1 = new ImageIcon(this.getClass().getResource("/img/snake-icon.png")).getImage();
    snakeIcon.setIcon(new ImageIcon(img1));
    add(snakeIcon);

    lblWelcome = new JLabel("Welcome to Snake-Emulator");
    lblWelcome.setFont(new Font("Lucida Grande", Font.BOLD | Font.ITALIC, 35));
    lblWelcome.setBounds(68, 70, 522, 44);
    add(lblWelcome);

    lblUsername = new JLabel("Username:"******"Lucida Grande", Font.PLAIN, 18));
    lblUsername.setBounds(126, 163, 98, 24);
    add(lblUsername);

    lblPassword = new JLabel("Password:"******"Lucida Grande", Font.PLAIN, 18));
    lblPassword.setBounds(126, 210, 98, 24);
    add(lblPassword);

    textFieldUsername = new JTextField();
    textFieldUsername.setFont(new Font("Lucida Grande", Font.PLAIN, 18));
    textFieldUsername.setBounds(226, 161, 174, 28);
    add(textFieldUsername);
    textFieldUsername.setColumns(10);

    passwordField = new JPasswordField();
    passwordField.setFont(new Font("Lucida Grande", Font.PLAIN, 18));
    passwordField.setBounds(226, 208, 174, 28);
    add(passwordField);

    btnLogin = new JButton("Login");
    btnLogin.setFont(new Font("Lucida Grande", Font.PLAIN, 18));
    btnLogin.setBounds(255, 248, 138, 36);
    add(btnLogin);

    lblDontHaveA = new JLabel("Don't have a user?");
    lblDontHaveA.setFont(new Font("Lucida Grande", Font.PLAIN, 18));
    lblDontHaveA.setBounds(78, 332, 164, 36);
    add(lblDontHaveA);

    btnSignUp = new JButton("Sign Up Here!");
    btnSignUp.setFont(new Font("Lucida Grande", Font.PLAIN, 18));
    btnSignUp.setBounds(243, 332, 164, 36);
    add(btnSignUp);

    lblYouHaveEntered = new JLabel("");
    lblYouHaveEntered.setFont(new Font("Lucida Grande", Font.PLAIN, 15));
    add(lblYouHaveEntered);
  }
Ejemplo n.º 24
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")));
  }
  /**
   * This method initializes passwordField
   *
   * @return javax.swing.JPasswordField
   */
  private JPasswordField getPasswordField() {
    if (passwordField == null) {
      passwordField = new JPasswordField();
      passwordField.addKeyListener(this);
      passwordField.setBounds(new java.awt.Rectangle(155, 222, 166, 21));
    }

    return passwordField;
  }
  public boolean validarClave() {
    boolean validado = true;

    if (!txtClave.getText().trim().equals(txtConfirmarClave.getText().trim())) {
      validado = false;
      JOptionPane.showMessageDialog(null, "Confirme su clave");
    }
    return validado;
  }
Ejemplo n.º 27
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);
 }
Ejemplo n.º 28
0
  /** 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);
  }
Ejemplo n.º 29
0
  // appelé lorsqu'on appuie sur le bouton "ok"
  public void check() {

    if (!Share.Tools.isSamePassword(password.getPassword(), password2.getPassword())) {
      // Couleur rouge
      color = new Color(255, 0, 0);
      // Permet de changer la couleur
      password.setForeground(color);
      password2.setForeground(color);
    }
  }
  /** Limpa os campos da janela */
  @Override
  public void limparCampos() {
    inserirBordasPadrao();

    loginTextField.setText("");
    passwordField.setText("");
    rPasswordField.setText("");

    rdbtnAdministrador.setSelected(true);
  }