if (path[i].equals(oldSelectedItem))
if ((i + 1) < path.length && path[i + 1].equals(oldSelectedItem))
  public void setSelectedPath(MenuElement[] path)  {    if (path == null)      {	clearSelectedPath();	return;      }    int i;    int minSize = path.length; // size of the smaller path.     if (path.length > selectedPath.size())      {	minSize = selectedPath.size();	// if new selected path contains more elements then current	// selection then first add all elements at 	// the indexes > selectedPath.size 	for (i = selectedPath.size(); i < path.length; i++)	  {	    selectedPath.add(path[i]);	    path[i].menuSelectionChanged(true);	  }      }    else if (path.length < selectedPath.size())      {	// if new selected path contains less elements then current 	// selection then first remove all elements from the selection	// at the indexes > path.length	for (i = selectedPath.size() - 1; i >= path.length; i--)	  {	    ((MenuElement) selectedPath.get(i)).menuSelectionChanged(false);	    selectedPath.remove(i);	  }	minSize = path.length;      }    // Now compare elements in new and current selection path at the     // same location and adjust selection until     // same menu elements will be encountered at the    // same index in both current and new selection path.    MenuElement oldSelectedItem;    for (i = minSize - 1; i >= 0; i--)      {	oldSelectedItem = (MenuElement) selectedPath.get(i);	if (path[i].equals(oldSelectedItem))	  break;	oldSelectedItem.menuSelectionChanged(false);	path[i].menuSelectionChanged(true);	selectedPath.setElementAt(path[i], i);      }    fireStateChanged();  }