public void downloadPathPanelDidEnd_returnCode_contextInfo(
     NSOpenPanel sheet, int returncode, ID contextInfo) {
   if (returncode == SheetCallback.DEFAULT_OPTION) {
     NSArray selected = sheet.filenames();
     if ((selected.lastObject()) != null) {
       host.setDownloadFolder(LocalFactory.createLocal(selected.lastObject().toString()));
     }
   }
   downloadPathPopup
       .itemAtIndex(new NSInteger(0))
       .setTitle(host.getDownloadFolder().getDisplayName());
   downloadPathPopup
       .itemAtIndex(new NSInteger(0))
       .setRepresentedObject(host.getDownloadFolder().getAbsolute());
   downloadPathPopup
       .itemAtIndex(new NSInteger(0))
       .setImage(IconCache.instance().iconForPath(host.getDownloadFolder(), 16));
   downloadPathPopup.selectItemAtIndex(new NSInteger(0));
   downloadPathPanel = null;
   this.itemChanged();
 }
  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);
    }
  }