aspose file tools
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
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply 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
Ranch Hand

Joined: Jul 11, 2001
Posts: 15230

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

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: 32830
    
    4
Welcome to JavaRanch I think that, short of Gregg's writing the method for you, he has given you all you require.
Gregg Bolinger
Ranch Hand

Joined: Jul 11, 2001
Posts: 15230

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: 32830
    
    4
You're welcome But, it's not thnx but thanks; read this
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: i want to read from a textfield and compare it with an external file
 
Similar Threads
Use of RandomAccessFile class under Swing
help with counting operands and operaters
error in retrieving from file.
Perl regex
Reading data from text file and comparing it with a string