I have put few elements in array (e.g. 5 elements) The first element, index[0] of the array will automatically displayed without the user need to click the button.
After the button clicked, it will print the next elements of array and the processes continue until the last element of array. Everytimes the button clicked, a file will be written on txt file.
My problem here was, there are e.g. 5 elements of array (successfully displayed when button clicked), however only four files written on txt file. How to make it five...Helppp... Im in a dead road :-(
public class mainFrame extends JFrame implements ActionListener {
........
private JButton answer1 = new JButton();
String [] a = {"a","b","c","d","e"}
in fileNumber = 0;
}
public mainFramme (){
System.out.println(a.get(fileNumber))
fileNumber++;
answer1.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource==answer1) {
System.out.println(a.get(fileNumber))
try {
.....
fout = new FileOutputStream ("myfile.txt",true);
Filename = new File(files.get(fileNumber));
new PrintStream(fout).println (Filename);
new PrintStream(fout).println ("Answer 1");
fileNumber++;
}
...
}
}