MenuBar.lookup(String) and MenuBar.lookupAll(String) do not search the Menus and MenuItems added to it directly or indirectly, probably because they do not inherit from Node/Parent.
Recursive lookup methods are useful for decoupling client code from the actual MenuBar tree structure. This will facilitate flexible and dynamic menus, which would otherwise require maintaining references to all the relevant MenuItems to avoid using brittle hard-coded train wrecks such as menuBar.getMenus().get(2).getItems().get(4).
GUI unit testing would also greatly benefit from structure-independent lookup methods.
A related issue is that lookup() and lookupAll() return a Node and a Set<Node>, respectively. Since MenuItem is not a subclass of Node, obviously MenuItem instances cannot be returned.
Recursive lookup methods are useful for decoupling client code from the actual MenuBar tree structure. This will facilitate flexible and dynamic menus, which would otherwise require maintaining references to all the relevant MenuItems to avoid using brittle hard-coded train wrecks such as menuBar.getMenus().get(2).getItems().get(4).
GUI unit testing would also greatly benefit from structure-independent lookup methods.
A related issue is that lookup() and lookupAll() return a Node and a Set<Node>, respectively. Since MenuItem is not a subclass of Node, obviously MenuItem instances cannot be returned.