Is it possible to create a user login using processing?

edited September 2015 in How To...

Hi guys! I'm just wondering if is it possible to create a "User login type" interface using processing IDE, the inputted username and password is fetched from a Database table "Users", and once the username and password is correct, the user will be automatically directed to a "member page/interface", if so, can you show me a sample code? Thanks guys!


  • edited July 2014 Answer ✓

    I've got this example from this thread link:

     * Hidden Password Input (v1.1)
     * by GoToLoop (2013/Dec)
     * how-to-create-an-interface-asking-username-and-correct-password-
     * is-it-possible-to-create-a-user-login-using-processing
    import static javax.swing.JOptionPane.*;
    import javax.swing.JPasswordField;
    final StringDict accounts = new StringDict(
    new String[] {
      "baptiste", "tanguy", "alexis"
    , new String[] {
      "bap", "guy", "ex"
    final JPasswordField pwd = new JPasswordField();
    void draw() {
      if (frameCount == 1)  frame.setVisible(false);
      String user = askUser();
      if (user == null)           confirmQuit();
      else if (!"".equals(user))  askPass(user);
    String askUser() {
      String id = showInputDialog("Please enter user:");
      if (id == null)
        showMessageDialog(null, "You've canceled login operation!"
          , "Alert", ERROR_MESSAGE);
      else if ("".equals(id))
        showMessageDialog(null, "Empty user input!"
          , "Alert", ERROR_MESSAGE);
      else if (!accounts.hasKey(id = id.toLowerCase()))
        showMessageDialog(null, "Unknown \"" + id + "\" user!" + (id = "")
          , "Alert", ERROR_MESSAGE);
      return id;
    boolean askPass(String id) {
      boolean isLogged = false;
      int action = showConfirmDialog(null, pwd
        , "Now enter password:", OK_CANCEL_OPTION);
      if (action != OK_OPTION) {
        showMessageDialog(null, "Password input canceled!"
          , "Alert", ERROR_MESSAGE);
        return false;
      String phrase = pwd.getText();
      //String phrase = new String(pwd.getPassword());
      if ("".equals(phrase))
        showMessageDialog(null, "Empty password input!"
          , "Alert", ERROR_MESSAGE);
      else if (accounts.get(id).equals(phrase)) {
        showMessageDialog(null, "Welcome \"" + id + "\"!\nYou're logged in!"
          , "Info", INFORMATION_MESSAGE);
        isLogged = true;
        showMessageDialog(null, "Password \"" + phrase + "\" mismatch!"
          , "Alert", ERROR_MESSAGE);
      return isLogged;
    void confirmQuit() {
      if (showConfirmDialog(null, "Wanna quit then?", "Exit"
        , OK_CANCEL_OPTION) == OK_OPTION)  exit();
  • Sir, thank you so much for this!!!! :D I'm going to start studying this code to create my own :)

  • Why is this topic in the Developing Processing category? Do you plan to add user authentication to the PDE?

    I suppose not, so I move this topic.

  • Oops! wrong category XD my bad... anyway thanks.

Sign In or Register to comment.