I am trying to step through a ArrayList<JPanel>
which contains ChartPanels
. The Next
button correctly steps through the charts as expected, but when I click the Previous
button nothing happens. I feel like my logic may be convoluted. Thanks!
Note: panelCombination
is a JPanel
.
Code for the buttons:
public static int advance = 0;
public static ArrayList<JPanel> chartList = new ArrayList<>();
private void NextMouseClicked(java.awt.event.MouseEvent evt) {
panelCombination.removeAll();
panelCombination.add(chartList.get(advance));
panelCombination.validate();
if (advance < chartList.size()-1) {
advance++;
}
}
private void PreviousMouseClicked(java.awt.event.MouseEvent evt) {
if (advance > 0) {
advance--;
}
panelCombination.removeAll();
panelCombination.add(chartList.get(advance));
panelCombination.validate();
}