1 Reply Latest reply: Jun 8, 2010 1:34 PM by 843807 RSS

    username and password

    843807
      ok so far ive got the password working

      public void actionPerformed( ActionEvent evt)
      *{*

      String cmd = evt.getActionCommand();

      if (password.equals(cmd)&& name.equals(cmd))
      *{ //Process the password.*
      char[] input = menupasswordtext.getPassword();
      if (isPasswordCorrect(input))
      *{*
      options();
      menuframe.setVisible(false);
      *}*
      *else {*
      JOptionPane.showMessageDialog(menuframe,
      *"Invalid password. Try again.",*
      *"Error Message",*
      JOptionPane.ERROR_MESSAGE);
      *}*
      *}*
      *}*
      *private static boolean isPasswordCorrect(char[] input) {*
      boolean isCorrect = true;
      *char[] correctPassword = { 'p', 'a', 's', 's', 'w', 'o', 'r','d' };*
      *if (input.length != correctPassword.length) {*
      isCorrect = false;
      *} else {*
      isCorrect = Arrays.equals (input, correctPassword);
      *}*

      *//Zero out the password.*
      Arrays.fill(correctPassword,'0');

      return isCorrect;
      *}*


      but im trying now to put together a username with that password but i dont know how to. im using a textfield for the username just trying to put that together with the passwordfield.

      any ideas?
        • 1. Re: username and password
          843807
          You need to use code tags to post your code to retain formatting and so the forum software does not corrupt your code. Please post new clean formatted source for your question and use code tags so we can read through uncorrupted code.