wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes i want to read from a textfield and compare it with an external file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "i want to read from a textfield and compare it with an external file" Watch "i want to read from a textfield and compare it with an external file" New topic
Author

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

Alex Hattie
Greenhorn

Joined: Jan 10, 2010
Posts: 3
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

Joined: Jul 11, 2001
Posts: 15299
    
    6

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.


GenRocket - Experts at Building Test Data
Alex Hattie
Greenhorn

Joined: Jan 10, 2010
Posts: 3
can you give me a short example please, i am a little bit new in java

thank you!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38765
    
  23
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

Joined: Jul 11, 2001
Posts: 15299
    
    6

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

Joined: Jan 10, 2010
Posts: 3
ok, thnx a lot guys!!!

thank you!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38765
    
  23
You're welcome But, it's not thnx but thanks; read this
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: i want to read from a textfield and compare it with an external file