I have an ArrayList which holds employee record details from data inputted into JTextFields. I have displayed this with a showMessageDialog box to confirm that they are being added to the list correctly.
The employees are created and added to the list correctly but how do I cycle through the ArrayList one record at a time and have the information displayed in the JTextFields?
Edited as below:
I don't think I have asked the question properly. I have a button that enables me to show the contents of the first element of my array list to the GUI. See below:
nField.setText(nameList.get(0).getName());
bField.setText(nameList.get(0).getBirth());
jField.setText(nameList.get(0).getID());
What I need is something to show the next element.
I have a list iterator that I am trying to use but I simply can’t get it to work.
I have tried this but it results in the last element being shown:
for (int i = 0; i < nameList.size(); i++) {
nameList.get(i);
nField.setText(nameList.get(i).getName());
bField.setText(nameList.get(i).getBirth());
jfield.setText(nameList.get(i).getID()); }