Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

i want to read from a textfield and compare it with an external file

 
Alex Hattie
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello, i want to fetch from a text field the text and compare it with another text in a database or in a local file.
any ideas?

thank you!!!
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gget the text from the text field and store it in a String. Get the data from the database/text file, store it in a string. Then use the equals() method of the String class.
 
Alex Hattie
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you give me a short example please, i am a little bit new in java

thank you!
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch I think that, short of Gregg's writing the method for you, he has given you all you require.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, we would want to tackle this in steps. So I'd say the first thing, considering this is the swing forum, is to get the text from a JTextField. One good place to start is the API for the JTextField. BTW, you should bookmark the API. It will become your best friend. Note there is a getText() method you can use to get the text. Store that value in a String.

The next part, getting a value from a database/file is a different bird all together. You should ask how to do that in the appropriate forums. We have one for JDBC and I/O & Streams. Decide which you want to tackle, do a little research, try some sample code, then come back and ask us more specific questions about where you are stuck.
 
Alex Hattie
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, thnx a lot guys!!!

thank you!
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome But, it's not thnx but thanks; read this
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic