I would be grateful if someone can come up with some suggestions please, ( I am currently revising for an exam).I have been having trouble reading consecutive lines from a text file using scanner through an actionListener event (button press or a mouseListener event, mousePressed); so that each button press reads the first line of text and the next button press reads the second line and so on. I cannot use a collection to store the text first.
I have put together a small example of what i am trying. I can read the whole text file no problem and i can read the first line of text without a problem. I have considered using some form of count comparison but cannot get that to work either. There are various commented out statements included as part of my attempts. Thanks
Please ignore my request I have finally solved the problem. By declaring the scanner object as an instance variable and instantiating it in the constructor inside a try catch block and removing the matching code from the button watcher, it all works.
subject: Reading consecutive text file lines using scanner and actionListener event