This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Login GUI and invalid attempts  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do anyone have any ideas how I can complete my code for when a user login using their username/password it is compared to a text file with pre-listed name/password? If their name is not in the file it error out and the box closes.


 
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to TellTheDetails.
What is the format of your data in the text file? "name=value" ? If yes, you can consider using the Properties class.

In pseudo code
1) When the application comes up, load the properties from the file
2) Accept user name + password from the user
3) Look up properties for a match
4) Process accordingly

I noticed you are using a null layout which is always a bad idea. you should be using a proper layout manager instead
 
Raziel Shabazz
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The steps you listed is what I'm looking for. Do you have examples I can read. When the applications starts it do need to read my text file
 
Raziel Shabazz
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I crashed my code. I was getting the GUI dialog box now I get nothing. Any wise Guru's up to helping me out?

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you should use the following code for reading a text file:

FileInputStream fs = new FileInputStream("users.txt");
DataInputStream in = new DataInputStream(fs);
BufferedReader br = new BufferedReader(new InputStreamReader(in));

Note that it is also wise for you to use a Vector class or any Collection interface.
This will help you for reading your file easily especially when you are reading many records.

You should create a separate class for reading then there you create your Vector object and convert it to string or 2D array of string.
Then, do the searching with the string or the 2D array.

If you want to manipulate the file use String Builder.

Hope this will help.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!