private void globalAccelFromMenu(MenuElement me){
  for (  MenuElement element : me.getSubElements()) {
    if ((element instanceof JPopupMenu) || (element instanceof JMenu)) {
      globalAccelFromMenu(element);
    }
 else     if (element instanceof JMenuItem) {
      JMenuItem item=(JMenuItem)element;
      if (item.getAccelerator() != null) {
        actionListenerMap.put(item.getAccelerator(),item.getActionListeners());
      }
    }
  }
}

private void globalAccelFromMenu ( MenuElement me ) { for ( MenuElement element : me . getSubElements ( ) ) { if ( ( element instanceof JPopupMenu ) || ( element instanceof JMenu ) ) { globalAccelFromMenu ( element ) ; } else if ( element instanceof JMenuItem ) { JMenuItem item = ( JMenuItem ) element ; if ( item . getAccelerator ( ) != null ) { actionListenerMap . put ( item . getAccelerator ( ) , item . getActionListeners ( ) ) ; } } } }
add accelerators to the global action map of maingui . this function will traverse a menuelement tree to find all jmenuitems and to add accelerators if available for the given menu item . the element tree is traversed in a recursive manner .
