Skip to content

MenuBar

Top-level horizontal menu bar hosting dropdown menus with command binding, keyboard accelerators, and popup coordination.

Overview

Top-level horizontal menu bar hosting dropdown menus with command binding, keyboard accelerators, and popup coordination. Provides extensive layout configuration and interaction capabilities.

Basic Usage

MenuBar menuBar = new MenuBar();
menuBar.menu(fileMenu).menu(editMenu);
  • Menu: Floating popup or dropdown menu widget hosting a vertical stack of menu items, command triggers, and separators.
  • MenuItem: Selectable menu entry supporting regular actions, checkboxes, commands, keyboard shortcuts, or cascading submenus.

API

Constructs an empty top-level MenuBar.

MenuBar::clearMenus()

Removes all menus from the menu bar.

Returns MenuBar: This instance for chaining..

MenuBar::closeOpenMenu()

Closes the active dropdown menu.

Returns MenuBar: This instance for chaining..

MenuBar::commandManager()

Returns the CommandManager used to resolve commands and shortcut bindings.

Returns CommandManager: The associated CommandManager..

MenuBar::commandManager(CommandManager)

Sets the CommandManager used to execute menu commands.

Parameter Type Description
commandManager CommandManager The CommandManager instance.

Returns MenuBar: This instance for chaining..

Appends a top-level Menu to the menu bar.

Parameter Type Description
menu Menu The menu instance.

Returns MenuBar: This instance for chaining..

Finds a top-level menu by its label, or returns null if not found.

Parameter Type Description
label String The label text.

Returns Menu: The menu instance..

Returns the number of top-level menus in the menu bar.

Returns int: The total item count..

Returns an unmodifiable list of top-level menus.

Returns List: An unmodifiable list of menus..

Replaces the entire list of top-level menus.

Parameter Type Description
menus List The list of menus.

Returns MenuBar: This instance for chaining..

MenuBar::openMenu(int)

Opens the dropdown menu at the specified index.

Parameter Type Description
index int The index position.

Returns MenuBar: This instance for chaining..

MenuBar::openedMenuIndex()

Returns the index of the currently opened dropdown menu, or -1 if closed.

Returns int: The result value..

MenuBar::openedPopup()

Returns the active dropdown ContextMenu popup widget, or null if closed.

Returns ContextMenu: The floating popup container..