Beispiel #1
0
 /**
  * returns a tree of all <code>JMenuItem</code> nodes the menu contains (omitting Strings and
  * Separators). The tree is build from <code>DefaultMutableTreeNode</code> nodes having <code>
  * MenuEntry</code> objects as their userObjects.
  *
  * <p>Note that the root node may have null as userObject if the menu item at <code>menuRootKey
  * </code> doesn't contain a <code>JMenuItem</code>!
  *
  * @param menuRootKey the key of the node that should form the root of the output.
  * @param menuBuilder access point for the menu(s).
  */
 public static DefaultMutableTreeNode createMenuEntryTree(
     final String menuRootKey, final MenuBuilder menuBuilder) {
   final HashMap<String, KeyStroke> menuKeyToKeyStrokeMap =
       MenuUtils.invertAcceleratorMap(menuBuilder.getAcceleratorMap());
   final DefaultMutableTreeNode menuRoot = menuBuilder.get(menuRootKey);
   final DefaultMutableTreeNode treeRoot =
       new DefaultMutableTreeNode(
           MenuUtils.menuNode2menuEntryNode(menuRoot, menuKeyToKeyStrokeMap));
   MenuUtils.addChildrenRecursively(treeRoot, menuRoot.children(), menuKeyToKeyStrokeMap);
   return treeRoot;
 }