if (shortcut != null)
if (item.isEnabled() && shortcut != null)
  public boolean postProcessKeyEvent (KeyEvent e)  {    // Check if this event represents a menu shortcut.    // MenuShortcuts are activated by Ctrl- KeyEvents, only on KEY_PRESSED.    int modifiers = e.getModifiersEx ();    if (e.getID() == KeyEvent.KEY_PRESSED        && (modifiers & KeyEvent.CTRL_DOWN_MASK) != 0)      {        Window focusedWindow = getGlobalFocusedWindow ();        if (focusedWindow instanceof Frame)          {            MenuBar menubar = ((Frame) focusedWindow).getMenuBar ();            if (menubar != null)  {                // If there's a menubar, loop through all menu items,                // checking whether each one has a shortcut, and if                // so, whether this key event should activate it.                int numMenus = menubar.getMenuCount ();                for (int i = 0; i < numMenus; i++)                  {                    Menu menu = menubar.getMenu (i);                    int numItems = menu.getItemCount ();                    for (int j = 0; j < numItems; j++)                      {                        MenuItem item = menu.getItem (j);                        MenuShortcut shortcut = item.getShortcut ();                        if (shortcut != null)                          {                            // Dispatch a new ActionEvent if:                            //                            //     a) this is a Shift- KeyEvent, and the                            //        shortcut requires the Shift modifier                            //                            // or, b) this is not a Shift- KeyEvent, and the                            //        shortcut does not require the Shift                            //        modifier.                            if (shortcut.getKey () == e.getKeyCode ()                                && ((shortcut.usesShiftModifier ()                                     && (modifiers & KeyEvent.SHIFT_DOWN_MASK) != 0)                                    || (! shortcut.usesShiftModifier ()                                        && (modifiers & KeyEvent.SHIFT_DOWN_MASK) == 0)))                              {                                item.dispatchEvent (new ActionEvent (item,                                                                     ActionEvent.ACTION_PERFORMED,                                                                     item.getActionCommand (),                                                                     modifiers));                                // The event was dispatched.                                return true;                              }  }                      }                  }              }          }      }    return false;  }