Please help me correct my if statements. I am trying to navigate through the arraylist elements but in some cases next and previous button displays command line errors. the errors vary but they have in common the following...
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index....
heres the code
public class buttonListener implements ActionListener {
public void actionPerformed(ActionEvent x){
if (x.getSource() == nxtButton){
indexCounter++;
balanceFrame.setVisible(false);
callDetail();
if(indexCounter == filePaths.size()-1) { //max counter...we dont want to exceed the max number, size of array
indexCounter = -1;
}
}
else if (x.getSource() == prevButton){
indexCounter--;
balanceFrame.setVisible(false);
callDetail();
if(indexCounter == 0){
indexCounter = filePaths.size()-1;
}
}
}}