Class MenuButton

java.lang.Object
All Implemented Interfaces:
Styleable, EventTarget, Skinnable
Direct Known Subclasses:
SplitMenuButton

public class MenuButton extends ButtonBase
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"));
Image of the MenuButton control

MnemonicParsing is enabled by default for MenuButton.

Since:
JavaFX 2.0
See Also: