for (int i=0; i<commands.size(); i++) ((SoftButton)sbArray.elementAt(i)).setCommand((Command)commands.elementAt(i));
for (int i=0; i<commands.size(); i++) { for (int j = 0; j < sbArray.size(); j++) { if (((SoftButton)sbArray.elementAt(j)).setCommand((Command)commands.elementAt(i))) { break; } } }
    public void updateCommands(Vector commands)     {        // Verify that the list is ordered        // Really an assert condition leave till all working        if (commands != null) {          for (int i=0; i<commands.size()-1; i++) {              Command cmda = (Command)commands.elementAt(i);              Command cmdb = (Command)commands.elementAt((i+1));              if (cmda.getPriority() > cmdb.getPriority()) {                  System.err.println("Assert: CommandManager.updateCommands commands out of order");              }          }        }        // Count how many soft buttons we have and remove the        // old commands while we are there        Vector devButtons = DeviceFactory.getDevice().getSoftButtons();        Vector sbArray = new Vector(3);        for (int i=0; i<devButtons.size(); i++) {          SoftButton button = (SoftButton) devButtons.elementAt(i);          if (button instanceof SoftButton) {            sbArray.addElement(button);            button.removeCommand();            button.setMenuActivate(false);          }        }        if (commands == null) {          return;        }                  int nSoftButtons = sbArray.size();        if (isMenuCommands(commands, nSoftButtons) == true) {            /* Special case if we have our BACK, SELECT commands */            ((SoftButton)sbArray.elementAt(0)).setCommand(BACK_COMMAND);            ((SoftButton)sbArray.elementAt(nSoftButtons-1)).setCommand(SELECT_COMMAND);        } else if (nSoftButtons >= commands.size()) {            /* No menus or special menus need to be created */            for (int i=0; i<commands.size(); i++)                ((SoftButton)sbArray.elementAt(i)).setCommand((Command)commands.elementAt(i));        } else {            /* Menu needed */            // Fill out the most important ones we can            for (int i=0; i<nSoftButtons-1; i++)                ((SoftButton)sbArray.elementAt(i)).setCommand((Command)commands.elementAt(i));            // Now we need a menu for the rest of the items            // Clear the commandList            while (commandList.size() > 0)                commandList.delete(0);            menuCommands.removeAllElements();            for (int i=nSoftButtons-1; i<commands.size(); i++) {                Command tmpC = (Command)commands.elementAt(i);                menuCommands.addElement(tmpC);                commandList.append(tmpC.getLabel(), null);        }        // Now set it up to be a menu button, and select button        SoftButton menuSB = (SoftButton)sbArray.elementAt(nSoftButtons-1);        menuSB.setMenuActivate(true);        menuSB.removeCommand();        menuSB.setCommand(MENU_COMMAND);      }    }