Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Marshal
Posts: 74651
335
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 74651
335
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic