Index: src/lib/com/izforge/izpack/installer/InstallerFrame.java =================================================================== --- src/lib/com/izforge/izpack/installer/InstallerFrame.java (revision 2050) +++ src/lib/com/izforge/izpack/installer/InstallerFrame.java (working copy) @@ -1555,26 +1555,70 @@ // if this is not here, validation will // occur mutilple times while skipping panels through the recursion if(!isValid) return; - - installdata.curPanelNumber++; - if (!canShow(installdata.curPanelNumber)) + + // We try to show the next panel that we can. + int nextPanel = hasNavigateNext(last); + if (-1 != nextPanel) { - this.navigateNext(last); + installdata.curPanelNumber = nextPanel; + switchPanel(last); } - else + } + } + + /** + * Check to see if there is another panel that can be navigated to next. + * This checks the successive panels to see if at least one can be shown + * based on the conditions associated with the panels. + * @param last The panel to check from + * @return The panel that we can navigate to next or -1 if there is no panel + * that we can navigate next to + */ + public int hasNavigateNext(int last) + { + // Assume that we cannot navigate to another panel + int res = -1; + // Start from the panel given and check each one until we find one + // that we can navigate to or until there are no more panels + for (int panel = last + 1; res == -1 && panel < installdata.panels.size(); panel++) + { + // See if we can show this panel + if (canShow(panel)) { - if (isValid) - { - switchPanel(last); - } - else { - installdata.curPanelNumber--; - } + res = panel; } } + // Return the result + return res; } /** + * Check to see if there is another panel that can be navigated to previous. + * This checks the previous panels to see if at least one can be shown + * based on the conditions associated with the panels. + * @param last The panel to check from + * @return The panel that we can navigate to previous or -1 if there is no panel + * that we can navigate previous to + */ + public int hasNavigatePrevious(int last) + { + // Assume that we cannot navigate to another panel + int res = -1; + // Start from the panel given and check each one until we find one + // that we can navigate to or until there are no more panels + for (int panel = last - 1; res == -1 && panel >= 0; panel--) + { + // See if we can show this panel + if (canShow(panel)) + { + res = panel; + } + } + // Return the result + return res; + } + + /** * This function moves to the previous panel */ public void navigatePrevious() @@ -1587,17 +1631,12 @@ public void navigatePrevious(int last) { - if ((installdata.curPanelNumber > 0)) + // We try to show the previous panel that we can. + int prevPanel = hasNavigatePrevious(last); + if (-1 != prevPanel) { - installdata.curPanelNumber--; - if (!canShow(installdata.curPanelNumber)) - { - this.navigatePrevious(last); - } - else - { - switchPanel(last); - } + installdata.curPanelNumber = prevPanel; + switchPanel(last); } }