Package limn.components
Class Menu
java.lang.Object
limn.components.Menu
An ordered list of
MenuItems: the reusable content of a
PopupMenu (context menu / dropdown), a MenuBar top-level
entry, or a submenu. Pure model; presenters render it.
Menu file = new Menu()
.addItem("New", () -> newDoc())
.addItem("Open…", () -> open())
.addSeparator()
.addSubmenu("Recentes", recentsMenu);
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAppends an item, including a separator.Adds a checkable item.addCheck(I18nString label, boolean checked, Consumer<Boolean> onToggle) A checkable item whose label follows the UI language.A command item with a fixed label.addItem(I18nString label, Runnable action) Adds a command item.Adds a divider (collapsed if it would be leading/trailing/doubled at render time).addSubmenu(String label, Menu submenu) Adds a submenu item.addSubmenu(I18nString label, Menu submenu) A nested menu whose label follows the UI language.clear()Removes every item, so a menu whose contents are data (recent files, open windows, connected devices) can be rebuilt from that data.booleanisEmpty()Whether this menu has no items at all.items()The items, in order, an unmodifiable view.
-
Constructor Details
-
Menu
public Menu()
-
-
Method Details
-
add
Appends an item, including a separator. -
addItem
Adds a command item. -
addCheck
A checkable item whose label follows the UI language. -
addItem
A command item with a fixed label. -
addCheck
Adds a checkable item. -
addSeparator
Adds a divider (collapsed if it would be leading/trailing/doubled at render time). -
clear
Removes every item, so a menu whose contents are data (recent files, open windows, connected devices) can be rebuilt from that data.Rebuilt in place rather than replaced, and that is the reason this exists: a
MenuBarentry and aMenuItem.submenuboth hold theMenuinstance, so handing them a fresh one would leave every holder pointing at the list that is no longer current. Clearing bumpsmodCount()like any other mutation, so a popup already on screen rebuilds its geometry instead of drawing rows that are gone. -
items
The items, in order, an unmodifiable view. -
isEmpty
public boolean isEmpty()Whether this menu has no items at all.
-