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?
Code :
/*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
Re: Problem with LogIn - Multiple users
Can you explain in more detail what you are trying to do with the HashMap?
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..
Re: Problem with LogIn - Multiple users
Quote:
I cant get it working
Can you show the code with the problem and explain what is not working?
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
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?