Example #1
0
  private void refreshMenu() {

    // refresh the associated mnemonics, so that the keyboard shortcut
    // keys are properly renumbered...

    // get an enumeration to the elements of the current button group
    Enumeration e = frameRadioButtonMenuItemGroup.getElements();

    int displayedCount = 1;
    int currentMenuCount = 0;

    while (e.hasMoreElements()) {
      BaseRadioButtonMenuItem b = (BaseRadioButtonMenuItem) e.nextElement();

      // compute the key mnemonic based upon the currentMenuCount
      currentMenuCount = displayedCount;
      if (currentMenuCount > 9) {
        currentMenuCount /= 10;
      }
      b.setMnemonic(KeyEvent.VK_0 + currentMenuCount);
      b.setText(displayedCount + " " + b.getAssociatedFrame().getTitle());
      displayedCount++;
    }
  }