java.lang.Object
io.github.palexdev.materialfx.controls.MFXContextMenu.Builder
- Enclosing class:
- MFXContextMenu
Builder class that facilitates the creation of context menus with fluent api.
An example:
MFXContextMenuItem item1 = ...;
MFXContextMenuItem item2 = ...;
MFXContextMenuItem item3 = ...;
MFXContextMenuItem item4 = ...;
MFXContextMenuItem item5 = ...;
MFXContextMenuItem item6 = ...;
MFXContextMenu.Builder.build(owner)
.addItems(item1, item2)
.addLineSeparator()
.addItems(item3, item4)
.addLineSeparator()
.addItems(item5, item6)
.installAndGet();
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionaddItem(MFXContextMenuItem item) Adds the giver menu item to the items list.addItem(MFXContextMenuItem item, EventHandler<ActionEvent> action) Sets the given action on the given item, then adds it to the items list.addItems(MFXContextMenuItem... items) Adds the given menu items to the items list.Adds the given line which acts as a separator to the items list.addLineSeparator(Insets insets) Adds the given line which acts as a separator to the items list.addSeparator(Node node) Adds the given node which acts as a separator to the items list.static MFXContextMenu.Builderget()static LineCallsgetLineSeparator(Insets)with top-bottom insets of 4.static LinegetLineSeparator(Insets insets) Builds aLineseparator with startX of 0 and the givenInsets, which are used asVBoxmargins,VBox.setMargin(Node, Insets).Installs the built context menu then returns it.setPopupStyleableParent(Parent parent) Sets the node that has the necessary stylesheets to customize the popup.setShowAction(Consumer<MouseEvent> showAction) Sets the action to perform when a valid MouseEvent occurs.setShowCondition(Function<MouseEvent, Boolean> showCondition) Sets the condition on which the given MouseEvent should trigger theMFXContextMenu.showActionProperty().
-
Method Details
-
build
- Returns:
- a new Builder instance with the given owner for the MFXContextMenu
-
addItem
Adds the giver menu item to the items list. -
addItems
Adds the given menu items to the items list. -
addItem
Sets the given action on the given item, then adds it to the items list. -
addSeparator
Adds the given node which acts as a separator to the items list. -
addLineSeparator
Adds the given line which acts as a separator to the items list.The line is generated using
getLineSeparator(). -
addLineSeparator
Adds the given line which acts as a separator to the items list.The line is generated using
getLineSeparator(Insets). -
setShowCondition
Sets the condition on which the given MouseEvent should trigger theMFXContextMenu.showActionProperty(). -
setShowAction
Sets the action to perform when a valid MouseEvent occurs.- See Also:
-
setPopupStyleableParent
Sets the node that has the necessary stylesheets to customize the popup. -
get
- Returns:
- the built context menu
-
installAndGet
Installs the built context menu then returns it. -
getLineSeparator
CallsgetLineSeparator(Insets)with top-bottom insets of 4. -
getLineSeparator
Builds aLineseparator with startX of 0 and the givenInsets, which are used asVBoxmargins,VBox.setMargin(Node, Insets).
-