I would like to iterate through a list every time a button is pressed, using JButton, JTextField and event's ActionListener. So every time the "next" button is pressed the next item in the array should be displayed in a JTextField. I have already created the getters, setters and constructor, it's literally only the following piece I'm having trouble with.
@Override
public void actionPerformed(ActionEvent evt){
Object source = evt.getSource();
String[] item = getThing();
for(int i = 0; i < 3; i ++){
String currentI = item[i];
}
if(source.equals(btnNxt)){
txtDisplayField.setText(currentI);
}
}
In the if statement I receive an error "Cannot find symbol", referring to currentI.