Menu
Floating popup or dropdown menu widget hosting a vertical stack of menu items, command triggers, and separators.
Overview
Floating popup or dropdown menu widget hosting a vertical stack of menu items, command triggers, and separators. Provides extensive layout configuration and interaction capabilities.
Basic Usage
Menu fileMenu = new Menu("File")
.action("New", this::onNew)
.separator()
.action("Exit", this::onExit);
Related links
- MenuBar: Top-level horizontal menu bar hosting dropdown menus with command binding, keyboard accelerators, and popup coordination.
- MenuItem: Selectable menu entry supporting regular actions, checkboxes, commands, keyboard shortcuts, or cascading submenus.
API
Menu(String)
Constructs a Menu with the given display label.
| Parameter | Type | Description |
|---|---|---|
label |
String |
The label text. |
Menu(String, String)
Constructs a Menu with an explicit identifier and display label.
| Parameter | Type | Description |
|---|---|---|
id |
String |
The unique identifier. |
label |
String |
The label text. |
Menu::action(String, Runnable)
Appends an action item with label and callback.
| Parameter | Type | Description |
|---|---|---|
label |
String |
The label text. |
action |
Runnable |
The action callback. |
Returns Menu: This instance for chaining..
Menu::clear()
Clears all items from this menu.
Returns Menu: This instance for chaining..
Menu::command(String)
Appends an editor command item by command identifier.
| Parameter | Type | Description |
|---|---|---|
commandId |
String |
The command identifier. |
Returns Menu: This instance for chaining..
Menu::command(String, String)
Appends an editor command item with custom display label.
| Parameter | Type | Description |
|---|---|---|
commandId |
String |
The command identifier. |
label |
String |
The label text. |
Returns Menu: This instance for chaining..
Menu::id()
Returns the menu identifier string.
Returns String: The unique identifier string..
Menu::id(String)
Sets the menu identifier string.
| Parameter | Type | Description |
|---|---|---|
id |
String |
The unique identifier. |
Returns Menu: This instance for chaining..
Menu::item(MenuItem)
Appends a MenuItem to this menu.
| Parameter | Type | Description |
|---|---|---|
item |
MenuItem |
The target item. |
Returns Menu: This instance for chaining..
Menu::items()
Returns an unmodifiable list of menu items.
Returns List: An unmodifiable list of node items..
Menu::label()
Returns the menu display label.
Returns String: The label string..
Menu::label(String)
Sets the menu display label.
| Parameter | Type | Description |
|---|---|---|
label |
String |
The label text. |
Returns Menu: This instance for chaining..
Menu::separator()
Appends a visual separator divider.
Returns Menu: This instance for chaining..
Menu::submenu(Menu)
Appends a cascading nested submenu.
| Parameter | Type | Description |
|---|---|---|
submenu |
Menu |
The child submenu. |
Returns Menu: This instance for chaining..