Class MenuTools

java.lang.Object
qupath.lib.gui.tools.MenuTools

public class MenuTools extends Object
Static methods to help with creating and populating JavaFX menus.
Author:
Pete Bankhead
  • Constructor Details

    • MenuTools

      public MenuTools()
  • Method Details

    • createMenu

      public static Menu createMenu(String name, Object... items)
      Create a menu, optionally add new menu items with addMenuItems(List, Object...).
      Parameters:
      name -
      items -
      Returns:
      the newly-created and populated menu
    • addMenuItems

      public static Menu addMenuItems(Menu menu, Object... items)
      Add menu items to an existing menu. Items may be
      • a MenuItem
      • an Action
      • null (indicating that a separator should be added)
      Parameters:
      menu -
      items -
      Returns:
      the provided menu, so that this method can be nested inside other calls.
    • addMenuItems

      public static List<MenuItem> addMenuItems(List<MenuItem> menuItems, Object... items)
      Add menu items to the specified list. This is similar to addMenuItems(Menu, Object...) but makes it possible to work also with a ContextMenu in addition to a standard Menu.
      Parameters:
      menuItems - existing list to which items should be added, or null if a new list should be created
      items - the items that should be provided (MenuItems or Actions)
      Returns:
      the list containing the adding items (same as the original if provided)
    • getMenu

      public static Menu getMenu(List<Menu> menus, String name, boolean createMenu)
      Get a reference to an existing menu, optionally creating a new menu if it is not present.
      Parameters:
      menus -
      name -
      createMenu -
      Returns:
    • getFlattenedMenuItems

      public static List<MenuItem> getFlattenedMenuItems(List<? extends MenuItem> menuItems, boolean excludeMenusAndSeparators)
      Get a flattened list of all menu items recursively.
      Parameters:
      menuItems - initial list of items (some may themselves be menus)
      excludeMenusAndSeparators - if true, exclude all items that are themselves either menus or separators
      Returns:
    • getFlattenedMenuItems

      public static List<MenuItem> getFlattenedMenuItems(boolean excludeMenusAndSeparators, MenuItem... items)
      Get a flattened list of all menu items recursively.
      Parameters:
      excludeMenusAndSeparators - if true, exclude all items that are themselves either menus or separators
      items - initial array of items (some may themselves be menus)
      Returns: