I have no clue how to read a line from a text file and put it in a JTextField. I have this so far to create a text file and be able to change the text inside it by changing my JTextFields. An example of this:
public void outputFile() throws FileNotFoundException{
PrintStream output = new PrintStream(new FileOutputStream("test"));
output.println(jtextfield1.getText());
}
I run this method when I click on a button. It works and the text file is indeed being changed. The problem is that I want to read this newly changed text to my JTextField, and the reason for this is that I use removeAll() method when changing between the panels for this program, thus my JTextField will be set as default (empty) when going back to this panel again.
For instance if I have written "abc" in my JTextField and clicked "OK" button, then when going back to my panel with my JTextField - my JTextField has to stay at "abc" and not get resetted (thus being empty), and the solution for this is to read from a file (but a line only, as there are many JTextFields) in to JTextField.