Package qupath.lib.gui.tools
Class MenuTools
java.lang.Object
qupath.lib.gui.tools.MenuTools
Static methods to help with creating and populating JavaFX menus.
- Author:
- Pete Bankhead
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddMenuItems
(List<MenuItem> menuItems, Object... items) Add menu items to the specified list.static Menu
addMenuItems
(Menu menu, Object... items) Add menu items to an existing menu.static Menu
createMenu
(String name, Object... items) Create a menu, optionally add new menu items withaddMenuItems(List, Object...)
.getFlattenedMenuItems
(boolean excludeMenusAndSeparators, MenuItem... items) Get a flattened list of all menu items recursively.getFlattenedMenuItems
(List<? extends MenuItem> menuItems, boolean excludeMenusAndSeparators) Get a flattened list of all menu items recursively.static Menu
Get a reference to an existing menu, optionally creating a new menu if it is not present.
-
Constructor Details
-
MenuTools
public MenuTools()
-
-
Method Details
-
createMenu
Create a menu, optionally add new menu items withaddMenuItems(List, Object...)
.- Parameters:
name
-items
-- Returns:
- the newly-created and populated menu
-
addMenuItems
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.
- a
-
addMenuItems
Add menu items to the specified list. This is similar toaddMenuItems(Menu, Object...)
but makes it possible to work also with aContextMenu
in addition to a standardMenu
.- Parameters:
menuItems
- existing list to which items should be added, or null if a new list should be createditems
- the items that should be provided (MenuItems or Actions)- Returns:
- the list containing the adding items (same as the original if provided)
-
getMenu
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 separatorsitems
- initial array of items (some may themselves be menus)- Returns:
-