• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Sherly Changappa
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 50289
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 50289
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic