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.

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);

Re: Problem with LogIn - Multiple users

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 ...

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?