Laura
Laura

Reputation: 131

how to update a line from a file that I put in a JTextField

Maybe my title is not the best but here is what I really want.I have a file in which I have some lines.I have put each line in a JTextField. Here is an example. Let's say this is a line in a textfield

mary peterson teacher

Now what I want is to modify this line in the textfield and save it when I close the frame in the file like this

mary ruble teacher piano .

Can someone please give me an idea about how to do this?

Upvotes: 0

Views: 116

Answers (1)

Gilbert Le Blanc
Gilbert Le Blanc

Reputation: 51565

Basically, you break the problem into smaller and smaller steps until you know how to code each step.

You first have to create a Java Swing GUI that contains a JTextField and a JButton that tells your Java code to bring up the next line of text.

Here's one way of breaking up the problem.

  • Open input file
  • Open output file
  • Display first line in the JTextField
  • On JButton left click, write line from JTextField to output file, read next line from input file, display next line in the JTextField.
  • On end of input file, close input file, close output file.

Upvotes: 2

Related Questions