/* * Method: switchTabs * params:tabs - tabset we are operating on (JTabbedPane) * action - action to be performed (int) * * Provides a method to switch the
active interface tab. Works across * all modes of the application. Calls setNavButtons (JTabbedPane tabs) * to sync buttons states. */ public void switchTabs(JTabbedPane tabs, int action) { int currentTab = [Link](); // Get active tab switch (action) { case BACK: // Back button was clicked, move to the previous tab if (currentTab > 0) { // are we on the first tab? currentTab -= 1; while ( && currentTab > 0) { currentTab -= 1; // bypass disabled tabs } if (currentTab < 0) { //did we go too far? currentTab = 0; } [Link](currentTab); // set the new active tab } setNavButtons(tabs); // sync button state break; case NEXT: // Next button was clicked, move to the next tab if (currentTab < [Link]() - 1) { // are we on the last tab? currentTab += 1; while ( && currentTab <= [Link]() - 1) { currentTab += 1; // bypass disabled tabs } if (currentTab > [Link]() - 1) { // did we go too far? currentTab = [Link]() - 1; } [Link](currentTab); // set the new active tab } setNavButtons(tabs); // sync button state break; case RESET: // Reset button was clicked, reset the interface and objects [Link](0); //set active tab to the first tab resetForm(); // reset the entire interface and all objects setNavButtons(tabs); // sync button state break;
default: // fallthrough event should never be hit setNavButtons(tabs); // sync button state break; } processOrder(); // work, work, work }