if (selected && isEnabled()) { super.setArmed(true); super.setSelected(true);           if (isShowing()) { fireMenuSelected();  int x = 0; int y = 0;  if (menuLocation == null) {   if (isTopLevelMenu()) y = this.getHeight(); else x = this.getWidth();  getPopupMenu().show(this, x, y); } else getPopupMenu().show(this, menuLocation.x, menuLocation.y); } }  else { super.setSelected(false); super.setArmed(false); fireMenuDeselected(); popupMenu.setVisible(false); }
setSelectedHelper(selected, true, false);
  public void setSelected(boolean selected)  {    // If menu is selected and enabled, activates the menu and     // displays associated popup.	    if (selected && isEnabled())      {    super.setArmed(true);	super.setSelected(true);	// FIXME: The reference implementation behaves different here. When	// calling setSelected(true) it will *not* open the popup but appear	// selected. This is even true when the menu is disabled. Our	// implementation will always open the popup (when enabled) and 	// will not appear selected when disabled.	// FIXME: The popup menu should be shown on the screen after certain	// number of seconds pass. The 'delay' property of this menu indicates	// this amount of seconds. 'delay' property is 0 by default.	if (isShowing())	  {    fireMenuSelected();	    int x = 0;	    int y = 0;	    if (menuLocation == null)	      {		// Calculate correct position of the popup. Note that location of the popup 		// passed to show() should be relative to the popup's invoker		if (isTopLevelMenu())		  y = this.getHeight();		else		  x = this.getWidth();		getPopupMenu().show(this, x, y);	      }	    else	      getPopupMenu().show(this, menuLocation.x, menuLocation.y);	  }      }    else      {	super.setSelected(false);	super.setArmed(false);	fireMenuDeselected();	popupMenu.setVisible(false);      }  }