MenuButton is a button which, when clicked or pressed, will show a
ContextMenu
. A MenuButton shares a very similar API to the Menu
control, insofar that you set the items that should be shown in the
items
ObservableList, and there is a text
property to specify the
label shown within the MenuButton.
As mentioned, like the Menu API itself, you'll find an items
ObservableList
within which you can provide anything that extends from MenuItem
.
There are several useful subclasses of MenuItem
including
RadioMenuItem
, CheckMenuItem
, Menu
,
SeparatorMenuItem
and CustomMenuItem
.
A MenuButton can be set to show its menu on any side of the button. This is
specified using the popupSide
property. By default
the menu appears below the button. However, regardless of the popupSide specified,
if there is not enough room, the ContextMenu
will be
smartly repositioned, most probably to be on the opposite side of the
MenuButton.
Example:
MenuButton m = new MenuButton("Eats"); m.getItems().addAll(new MenuItem("Burger"), new MenuItem("Hot Dog"));
MnemonicParsing is enabled by default for MenuButton.
extends
MenuItem, Menu, SplitMenuButton