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.
MenuItem, Menu, SplitMenuButton
| Modifier and Type | Field and Description |
|---|---|
| private static final String | |
| private final ObservableList | |
| public static final EventType | ON_HIDDEN
Called when the MenuButton popup has been hidden. |
| public static final EventType | ON_HIDING
Called when the MenuButton popup will be hidden. |
| public static final EventType | ON_SHOWING
Called prior to the MenuButton showing its popup after the user has clicked or otherwise interacted with the MenuButton. |
| public static final EventType | ON_SHOWN
Called after the MenuButton has shown its popup. |
| private ObjectProperty | |
| private ObjectProperty | |
| private ObjectProperty | |
| private ObjectProperty | |
| private ObjectProperty | popupSide
Indicates on which side the |
| private static final PseudoClass | |
| private static final PseudoClass | |
| private ReadOnlyBooleanWrapper | showing
Indicates whether the |
| Access | Constructor and Description |
|---|---|
| public | |
| public | MenuButton(String
the text to display on the menu button text)Creates a new empty menu button with the given text to display on the button. |
| public | MenuButton(String
the text to display on the menu button text, Node the graphic to display on the menu button graphic)Creates a new empty menu button with the given text and graphic to display on the button. |
| public | MenuButton(String
the text to display on the menu button text, Node the graphic to display on the menu button graphic, MenuItem... The items to display in the popup menu. items)Creates a new menu button with the given text and graphic to
display on the button, and inserts the given items
into the |
| Modifier and Type | Method and Description |
|---|---|
| protected Skin | createDefaultSkin()
Overrides javafx. Create a new instance of the default skin for this control. |
| public void | executeAccessibleAction(AccessibleAction
the action to execute action, Object... optional list of parameters parameters)Overrides javafx. This method is called by the assistive technology to request the action indicated by the argument should be executed. |
| public void | |
| public final ObservableList | Returns: the list of menu items within this buttons menuThe items to show within this buttons menu. |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final EventHandler | |
| public final Side | |
| public void | |
| public final boolean | |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final ObjectProperty | Returns: the on showing propertyCalled just prior to the |
| public final ObjectProperty | |
| public final ObjectProperty | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| private void | |
| public void | |
| public final ReadOnlyBooleanProperty |
| DEFAULT_STYLE_CLASS | back to summary |
|---|---|
| private static final String DEFAULT_STYLE_CLASS | |
| items | back to summary |
|---|---|
| private final ObservableList<MenuItem> items | |
| ON_HIDDEN | back to summary |
|---|---|
| public static final EventType<Event> ON_HIDDEN Called when the MenuButton popup has been hidden.
| |
| ON_HIDING | back to summary |
|---|---|
| public static final EventType<Event> ON_HIDING Called when the MenuButton popup will be hidden.
| |
| ON_SHOWING | back to summary |
|---|---|
| public static final EventType<Event> ON_SHOWING Called prior to the MenuButton showing its popup after the user has clicked or otherwise interacted with the MenuButton.
| |
| ON_SHOWN | back to summary |
|---|---|
| public static final EventType<Event> ON_SHOWN Called after the MenuButton has shown its popup.
| |
| onHidden | back to summary |
|---|---|
| private ObjectProperty<EventHandler<Event>> onHidden | |
| onHiding | back to summary |
|---|---|
| private ObjectProperty<EventHandler<Event>> onHiding | |
| onShowing | back to summary |
|---|---|
| private ObjectProperty<EventHandler<Event>> onShowing | |
| onShown | back to summary |
|---|---|
| private ObjectProperty<EventHandler<Event>> onShown | |
| popupSide | back to summary |
|---|---|
| private ObjectProperty<Side> popupSide Indicates on which side the
| |
| PSEUDO_CLASS_OPENVERTICALLY | back to summary |
|---|---|
| private static final PseudoClass PSEUDO_CLASS_OPENVERTICALLY | |
| PSEUDO_CLASS_SHOWING | back to summary |
|---|---|
| private static final PseudoClass PSEUDO_CLASS_SHOWING | |
| showing | back to summary |
|---|---|
| private ReadOnlyBooleanWrapper showing Indicates whether the | |
| MenuButton | back to summary |
|---|---|
| public MenuButton() Creates a new empty menu button. Use | |
| MenuButton | back to summary |
|---|---|
| public MenuButton(String text) Creates a new empty menu button with the given text to display on the
button. Use
| |
| MenuButton | back to summary |
|---|---|
| public MenuButton(String text, Node graphic) Creates a new empty menu button with the given text and graphic to
display on the button. Use | |
| MenuButton | back to summary |
|---|---|
| public MenuButton(String text, Node graphic, MenuItem... items) Creates a new menu button with the given text and graphic to
display on the button, and inserts the given items
into the | |
| createDefaultSkin | back to summary |
|---|---|
| protected Skin Overrides javafx. Doc from javafx. Create a new instance of the default skin for this control. This is called to create a skin for the control if
no skin is provided via CSS | |
| executeAccessibleAction | back to summary |
|---|---|
| public void executeAccessibleAction(AccessibleAction action, Object... parameters) Overrides javafx. Doc from javafx. This method is called by the assistive technology to request the action indicated by the argument should be executed.
This method is commonly overridden by subclasses to implement
action that are required for a specific role.
| |
| fire | back to summary |
|---|---|
| public void fire() Implements abstract javafx. This has no impact.
| |
| getItems | back to summary |
|---|---|
| public final ObservableList The items to show within this buttons menu. If this ObservableList is modified at runtime, the Menu will update as expected.
Commonly used controls include including
| |
| getOnHidden | back to summary |
|---|---|
| public final EventHandler | |
| getOnHiding | back to summary |
|---|---|
| public final EventHandler | |
| getOnShowing | back to summary |
|---|---|
| public final EventHandler | |
| getOnShown | back to summary |
|---|---|
| public final EventHandler | |
| getPopupSide | back to summary |
|---|---|
| public final Side getPopupSide() | |
| hide | back to summary |
|---|---|
| public void hide() Hides the
| |
| isShowing | back to summary |
|---|---|
| public final boolean isShowing() | |
| onHiddenProperty | back to summary |
|---|---|
| public final ObjectProperty Called just after the
| |
| onHidingProperty | back to summary |
|---|---|
| public final ObjectProperty Called just prior to the
| |
| onShowingProperty | back to summary |
|---|---|
| public final ObjectProperty Called just prior to the
| |
| onShownProperty | back to summary |
|---|---|
| public final ObjectProperty Called just after the
| |
| popupSideProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| setOnHidden | back to summary |
|---|---|
| public final void setOnHidden(EventHandler<Event> value) | |
| setOnHiding | back to summary |
|---|---|
| public final void setOnHiding(EventHandler<Event> value) | |
| setOnShowing | back to summary |
|---|---|
| public final void setOnShowing(EventHandler<Event> value) | |
| setOnShown | back to summary |
|---|---|
| public final void setOnShown(EventHandler<Event> value) | |
| setPopupSide | back to summary |
|---|---|
| public final void setPopupSide(Side value) | |
| setShowing | back to summary |
|---|---|
| private void setShowing(boolean value) | |
| show | back to summary |
|---|---|
| public void show() Shows the
| |
| showingProperty | back to summary |
|---|---|
| public final ReadOnlyBooleanProperty showingProperty() | |