- java.lang.Object
- 
- javafx.scene.control.MenuItem
- 
- javafx.scene.control.CustomMenuItem
 
 
- 
- All Implemented Interfaces:
- Styleable,- EventTarget
 - Direct Known Subclasses:
- SeparatorMenuItem
 
 public class CustomMenuItem extends MenuItem A MenuItemthat allows for arbitrary nodes to be embedded within it, by assigning aNodeto thecontentproperty. CustomMenuItem attempts to make arbitrary nodes appear more natural in the Menu. For example, you automatically get hover highlighting when the user hovers their mouse over the node (or navigates to it using keyboard or other alternate means).A useful property of this class is hideOnClick. This boolean specifies whether the CustomMenuItem will be automatically hidden should the user click within the bounds of the CustomMenuItem. This is of particular use when the node inside this CustomMenuItem is a control that requires user interaction, as by setting the hideOnClick property to false means the user can interact with it without the menu hiding. Note that by default hideOnClick is true.An example of how to use CustomMenuItem is shown below. CustomMenuItem customMenuItem = new CustomMenuItem(new Slider()); customMenuItem.setHideOnClick(false);If this CustomMenuItem, with the Sliderwithin it, is placed in a menu, you'll be presented with a slider that is horizontally centered when the menu is visible, and interacting with the slider will not result in the menu disappearing.
- 
- 
Property SummaryProperties Type Property Description ObjectProperty<Node>contentThe node to display within this CustomMenuItem.BooleanPropertyhideOnClickIf true, this menu item, and all visible menus, will be hidden when this menu item is clicked on.- 
Properties inherited from class javafx.scene.control.MenuItemaccelerator, disable, graphic, id, mnemonicParsing, onAction, onMenuValidation, parentMenu, parentPopup, style, text, visible
 
- 
 - 
Field Summary- 
Fields inherited from class javafx.scene.control.MenuItemMENU_VALIDATION_EVENT
 
- 
 - 
Constructor SummaryConstructors Constructor Description CustomMenuItem()Creates a default CustomMenuItem instance.CustomMenuItem(Node node)Constructs a CustomMenuItem and initializes its content with the node specified.CustomMenuItem(Node node, boolean hideOnClick)Constructs a CustomMenuItem and sets the content to the node specified.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectProperty<Node>contentProperty()The node to display within this CustomMenuItem.NodegetContent()Gets the value of the property content.BooleanPropertyhideOnClickProperty()If true, this menu item, and all visible menus, will be hidden when this menu item is clicked on.booleanisHideOnClick()Gets the value of the property hideOnClick.voidsetContent(Node value)Sets the value of the property content.voidsetHideOnClick(boolean value)Sets the value of the property hideOnClick.- 
Methods inherited from class javafx.scene.control.MenuItemacceleratorProperty, addEventHandler, buildEventDispatchChain, disableProperty, fire, getAccelerator, getCssMetaData, getGraphic, getId, getOnAction, getOnMenuValidation, getParentMenu, getParentPopup, getProperties, getPseudoClassStates, getStyle, getStyleableNode, getStyleableParent, getStyleClass, getText, getTypeSelector, getUserData, graphicProperty, idProperty, isDisable, isMnemonicParsing, isVisible, mnemonicParsingProperty, onActionProperty, onMenuValidationProperty, parentMenuProperty, parentPopupProperty, removeEventHandler, setAccelerator, setDisable, setGraphic, setId, setMnemonicParsing, setOnAction, setOnMenuValidation, setParentMenu, setParentPopup, setStyle, setText, setUserData, setVisible, styleProperty, textProperty, toString, visibleProperty
 
- 
 
- 
- 
- 
Property Detail- 
contentpublic final ObjectProperty<Node> contentProperty The node to display within this CustomMenuItem.- See Also:
- getContent(),- setContent(Node)
 
 - 
hideOnClickpublic final BooleanProperty hideOnClickProperty If true, this menu item, and all visible menus, will be hidden when this menu item is clicked on.- Default value:
- true
- See Also:
- isHideOnClick(),- setHideOnClick(boolean)
 
 
- 
 - 
Constructor Detail- 
CustomMenuItempublic CustomMenuItem() Creates a default CustomMenuItem instance.
 - 
CustomMenuItempublic CustomMenuItem(Node node) Constructs a CustomMenuItem and initializes its content with the node specified.- Parameters:
- node- to be embedded inside this CustomMenuItem
 
 - 
CustomMenuItempublic CustomMenuItem(Node node, boolean hideOnClick) Constructs a CustomMenuItem and sets the content to the node specified.- Parameters:
- node- to be embedded inside this CustomMenuItem
- hideOnClick- if false the menu will not hide when the user interacts with the node.
 
 
- 
 - 
Method Detail- 
setContentpublic final void setContent(Node value) Sets the value of the property content.- Property description:
- The node to display within this CustomMenuItem.
 
 - 
getContentpublic final Node getContent() Gets the value of the property content.- Property description:
- The node to display within this CustomMenuItem.
 
 - 
contentPropertypublic final ObjectProperty<Node> contentProperty() The node to display within this CustomMenuItem.- See Also:
- getContent(),- setContent(Node)
 
 - 
setHideOnClickpublic final void setHideOnClick(boolean value) Sets the value of the property hideOnClick.- Property description:
- If true, this menu item, and all visible menus, will be hidden when this menu item is clicked on.
- Default value:
- true
 
 - 
isHideOnClickpublic final boolean isHideOnClick() Gets the value of the property hideOnClick.- Property description:
- If true, this menu item, and all visible menus, will be hidden when this menu item is clicked on.
- Default value:
- true
 
 - 
hideOnClickPropertypublic final BooleanProperty hideOnClickProperty() If true, this menu item, and all visible menus, will be hidden when this menu item is clicked on.- Default value:
- true
- See Also:
- isHideOnClick(),- setHideOnClick(boolean)
 
 
- 
 
-