aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Fetching each word from a text file into text field in java. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Fetching each word from a text file into text field in java." Watch "Fetching each word from a text file into text field in java." New topic
Author

Fetching each word from a text file into text field in java.

Sherly Changappa
Greenhorn

Joined: Mar 26, 2013
Posts: 4
Hello,
I'm trying to fetch a set of words stored in a text file into a text field one after the other i.e in my form i have a text field and a button, when i click on the button the word present in the text file must be displayed in the text field and when i click the button again, the second word in the text file must be displayed in the text field and so on. I was able to write a program to fetch a single word but not in a loop. Please guide me with this issue. Thanks in advance.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38765
    
  23
Using getSource and == inside a method suggests to me you are using that most dreadfully non‑object‑oriented construct addActionListener(this).
Suggestion: There is a piece of hardware which is obstructing your progress with this assignment, and it must be removed. It is long thin and (probably) black, and it connects your computer to the wall. Remove that piece of hardware, and use a pencil paper and eraser to write how you intend to fetch a word from that file, and then set the text in your component. Also read the Scanner documentation.
Sherly Changappa
Greenhorn

Joined: Mar 26, 2013
Posts: 4
Thanks for your valuable suggestions.. If you are referring the hardware to be my internet connection then probably i wouldn't be able to do this much also without it.. I'm trying to self learn through samples.
Will surely give a thought on your suggestion.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38765
    
  23
The bit of hardware I was thinking of goes to the power supply.
And it is after 12 o’clock, so it is not a 1st April joke.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Fetching each word from a text file into text field in java.