Пример #1
0
  /**
   * adds a {@link com.tomtessier.scrollabledesktop.BaseRadioButtonMenuItem BaseRadioButtonMenuItem}
   * to the menu and associates it with an internal frame
   *
   * @param associatedFrame the internal frame to associate with the menu item
   */
  public void add(BaseInternalFrame associatedFrame) {

    int displayedCount = getItemCount() - baseItemsEndIndex + 1;
    int currentMenuCount = displayedCount;

    // compute the key mnemonic based upon the currentMenuCount
    if (currentMenuCount > 9) {
      currentMenuCount /= 10;
    }

    BaseRadioButtonMenuItem menuButton =
        new BaseRadioButtonMenuItem(
            this,
            displayedCount + " " + associatedFrame.getTitle(),
            KeyEvent.VK_0 + currentMenuCount,
            -1,
            true,
            associatedFrame);

    associatedFrame.setAssociatedMenuButton(menuButton);

    add(menuButton);
    frameRadioButtonMenuItemGroup.add(menuButton);

    menuButton.setSelected(true); // and reselect here, so that the
    // buttongroup recognizes the change

  }
  /**
   * insures that the associated toolbar and menu buttons of the internal frame are activated as
   * well
   *
   * @param f the internal frame being activated
   */
  public void activateFrame(JInternalFrame f) {

    super.activateFrame(f);
    ((BaseInternalFrame) f).selectFrameAndAssociatedButtons();
  }