public void setFilesPopup(final NSPopUpButton p) {
   this.filesPopup = p;
   this.filesPopup.setTarget(this.id());
   this.filesPopup.removeAllItems();
   for (Path path : transfer.getRoots()) {
     NSMenuItem item =
         this.filesPopup
             .menu()
             .addItemWithTitle_action_keyEquivalent(
                 path.getName(), Foundation.selector("reveal:"), StringUtils.EMPTY);
     item.setRepresentedObject(path.getAbsolute());
     item.setImage(IconCache.instance().iconForPath(path, 16, false));
   }
   this.filesPopupMenuDelegate = new TransferMenuDelegate(transfer);
   this.filesPopup.menu().setDelegate(this.filesPopupMenuDelegate.id());
   NSNotificationCenter.defaultCenter()
       .addObserver(
           this.id(),
           Foundation.selector("filesPopupWillShow:"),
           NSPopUpButton.PopUpButtonWillPopUpNotification,
           this.filesPopup);
   NSNotificationCenter.defaultCenter()
       .addObserver(
           this.id(),
           Foundation.selector("filesPopupWillHide:"),
           "NSMenuDidEndTrackingNotification",
           this.filesPopup.menu());
 }
 public void setProtocolPopup(NSPopUpButton protocolPopup) {
   this.protocolPopup = protocolPopup;
   this.protocolPopup.setEnabled(true);
   this.protocolPopup.setTarget(this.id());
   this.protocolPopup.setAction(Foundation.selector("protocolSelectionChanged:"));
   this.protocolPopup.removeAllItems();
   for (Protocol protocol : ProtocolFactory.getKnownProtocols()) {
     final String title = protocol.getDescription();
     this.protocolPopup.addItemWithTitle(title);
     final NSMenuItem item = this.protocolPopup.itemWithTitle(title);
     item.setRepresentedObject(String.valueOf(protocol.hashCode()));
     item.setImage(IconCache.iconNamed(protocol.icon(), 16));
   }
 }
  protected void makeScalePopUpButton() {
    if (_scalePopUpButton == null) {
      /* Create the pop up button. */
      _scalePopUpButton = new NSPopUpButton(new NSRect(0f, 0f, 1f, 1f), false);
      _scalePopUpButton.setBezelStyle(NSButtonCell.RegularSquareBezelStyle);

      /* Fill it with the scales. */
      int numberOfDefaultItems = MenuLabels.length;
      for (int i = 0; i < numberOfDefaultItems; i++) {
        String label = NSBundle.localizedString(MenuLabels[i]);
        _scalePopUpButton.addItem(label);

        NSMenuItem item = (NSMenuItem) _scalePopUpButton.itemAtIndex(i);

        if (ScaleFactors[i] != 0f) {
          Number factor = new Float(ScaleFactors[i]);
          item.setRepresentedObject(factor);
        }
      }
      _scalePopUpButton.selectItemAtIndex(DefaultSelectedItem);

      /* Hook it up. */
      _scalePopUpButton.setTarget(this);
      _scalePopUpButton.setAction(new NSSelector("scalePopUpAction", new Class[] {getClass()}));

      /* Pick a suitable font. */
      _scalePopUpButton.setFont(NSFont.toolTipsFontOfSize(10f));

      /* Make sure the pop up is big enough to fit the cells. */
      _scalePopUpButton.sizeToFit();

      /* Don't ever let it become the first responder. */
      _scalePopUpButton.setRefusesFirstResponder(true);

      /* Put it in the scroll view. */
      addSubview(_scalePopUpButton);
    }
  }