Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Problem with LogIn - Multiple users

  1. #1
    Member
    Join Date
    Apr 2012
    Posts
    57
    My Mood
    Angelic
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Problem with LogIn - Multiple users

    Hello,

    I'm doing a Log In frame. I managed to do a Simple LogIn function and now I got stuck with Multiple LogIn's. I found out that for this I can use HashMap. So I created the HashMap, but after that I'm not sure how to continue. Can somebody help me or give me some hints?


                          /*HashMap with parametrs */
                          Map <UserName,Pass> passbyUserName = new HashMap <userName,Passs>();
    		passbyUserName.put("Tech","TechN");
    		passbyUserName.put("Sys","SysO");
     
     
                           /*Trying to check if the input from WUserField(JTextField) exists in the HashMap same for the passwordField     which is JPasswordField......But Im sure thats it's not correct*/	
    		final boolean containsKey = passbyUserName.containsKey(WUserField);
    		final boolean containsValue = passbyUserName.containsValue(passwordField);

    Thx for your help


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,823
    Thanks
    55
    Thanked 2,344 Times in 2,315 Posts

    Default Re: Problem with LogIn - Multiple users

    Can you explain in more detail what you are trying to do with the HashMap?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Apr 2012
    Posts
    57
    My Mood
    Angelic
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Problem with LogIn - Multiple users

    Well, Yesterday night i was browsing java forums and I came accros this post : java - Accepting multiple username and password - Stack Overflow

    When somebody suggested to use HashMap in order to store the multiple users name and passwords. And because it looks kinda smart to store the unique pass's for different users in the Map. I tried to create it, but ...

    But I cant get it working in this way..

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,823
    Thanks
    55
    Thanked 2,344 Times in 2,315 Posts

    Default Re: Problem with LogIn - Multiple users

    I cant get it working
    Can you show the code with the problem and explain what is not working?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Member
    Join Date
    Apr 2012
    Posts
    57
    My Mood
    Angelic
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Problem with LogIn - Multiple users

    Well,

    I wrote sth but it wasn't working so I deleted it. Can you give me any advice how to make it with the HashMap? Or if I should use sth else?Thx

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,823
    Thanks
    55
    Thanked 2,344 Times in 2,315 Posts

    Default Re: Problem with LogIn - Multiple users

    Your code posted in post#1 has the right idea, but you need to read the API doc for the classes and variables you tried to use incorrectly.
    For example with this statement: Map <UserName,Pass>
    Are UserName and Pass the names of classes?
    and this statement: passbyUserName.containsKey(WUserField);
    What is WUserField? Can containsKey use its value?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [SOLVED] Problem with multiple output statements in DO WHILE loop.
    By Nismoz3255 in forum Loops & Control Statements
    Replies: 0
    Last Post: February 22nd, 2012, 09:14 PM
  2. Buttons and a Login problem
    By raja211991 in forum AWT / Java Swing
    Replies: 1
    Last Post: September 23rd, 2011, 03:41 PM
  3. Problem in a web that uses javascript in his login form
    By kamarilla in forum What's Wrong With My Code?
    Replies: 8
    Last Post: June 1st, 2011, 06:47 PM
  4. Java Web Browser Term Project- I am facing multiple problem...pls help
    By tazbinur in forum What's Wrong With My Code?
    Replies: 11
    Last Post: October 8th, 2010, 10:05 AM
  5. Completely Lost in this problem(multiple methods)
    By wacarter in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 31st, 2010, 05:44 PM