java.lang.Object
io.github.sosuisen.jfxbuilder.controls.MenuBuilder

public class MenuBuilder extends Object
The MenuBuilder class constructs instances of the Menu class and offers a fluent interface for creating and configuring it.

This class includes a static create method that accepts the same arguments as the original Menu constructor and returns an instance of the MenuBuilder.

You can use method chaining to call the builder methods for configuring the Menu. Finally, invoke the build method to generate an instance of the Menu class.

Note that intermediate builder methods are not evaluated until the build method is called, meaning they are evaluated lazily.

Author:
Hidekazu Kubota <hidekazu.kubota@gmail.com>
  • Method Details

    • create

      public static MenuBuilder create()
      Returns an instance of the MenuBuilder.
      Returns:
      an instance of the MenuBuilder.
    • create

      public static MenuBuilder create(String text)
      Accepts the constructor arguments of Menu(String) and returns an instance of MenuBuilder.
      Returns:
      an instance of the MenuBuilder.
    • create

      public static MenuBuilder create(String text, Node graphic)
      Accepts the constructor arguments of Menu(String, Node) and returns an instance of MenuBuilder.
      Returns:
      an instance of the MenuBuilder.
    • create

      public static MenuBuilder create(String text, Node graphic, MenuItem... items)
      Accepts the constructor arguments of Menu(String, Node, MenuItem...) and returns an instance of MenuBuilder.
      Returns:
      an instance of the MenuBuilder.
    • build

      public Menu build()
      Builds and returns an instance of the Menu class.

      Intermediate builder methods are not evaluated until the build method is called; in other words, they are evaluated lazily.

      Returns:
      new instance of the Menu class
    • apply

      public MenuBuilder apply(Consumer<Menu> func)
      Applies a function to the Menu instance being constructed. Most operations on the instance can be performed using this method.
      Returns:
      builder instance
    • accelerator

      public MenuBuilder accelerator(KeyCombination value)
      A builder method that invokes the setAccelerator method on the instance being constructed.
      Returns:
      builder instance
    • disable

      public MenuBuilder disable(boolean value)
      A builder method that invokes the setDisable method on the instance being constructed.
      Returns:
      builder instance
    • graphic

      public MenuBuilder graphic(Node value)
      A builder method that invokes the setGraphic method on the instance being constructed.
      Returns:
      builder instance
    • id

      public MenuBuilder id(String value)
      A builder method that invokes the setId method on the instance being constructed.
      Returns:
      builder instance
    • mnemonicParsing

      public MenuBuilder mnemonicParsing(boolean value)
      A builder method that invokes the setMnemonicParsing method on the instance being constructed.
      Returns:
      builder instance
    • onAction

      public MenuBuilder onAction(EventHandler<ActionEvent> value)
      A builder method that invokes the setOnAction method on the instance being constructed.
      Returns:
      builder instance
    • onHidden

      public MenuBuilder onHidden(EventHandler<Event> value)
      A builder method that invokes the setOnHidden method on the instance being constructed.
      Returns:
      builder instance
    • onHiding

      public MenuBuilder onHiding(EventHandler<Event> value)
      A builder method that invokes the setOnHiding method on the instance being constructed.
      Returns:
      builder instance
    • onMenuValidation

      public MenuBuilder onMenuValidation(EventHandler<Event> value)
      A builder method that invokes the setOnMenuValidation method on the instance being constructed.
      Returns:
      builder instance
    • onShowing

      public MenuBuilder onShowing(EventHandler<Event> value)
      A builder method that invokes the setOnShowing method on the instance being constructed.
      Returns:
      builder instance
    • onShown

      public MenuBuilder onShown(EventHandler<Event> value)
      A builder method that invokes the setOnShown method on the instance being constructed.
      Returns:
      builder instance
    • style

      public MenuBuilder style(String value)
      A builder method that invokes the setStyle method on the instance being constructed.
      Returns:
      builder instance
    • text

      public MenuBuilder text(String value)
      A builder method that invokes the setText method on the instance being constructed.
      Returns:
      builder instance
    • userData

      public MenuBuilder userData(Object value)
      A builder method that invokes the setUserData method on the instance being constructed.
      Returns:
      builder instance
    • visible

      public MenuBuilder visible(boolean value)
      A builder method that invokes the setVisible method on the instance being constructed.
      Returns:
      builder instance
    • addItems

      public final MenuBuilder addItems(MenuItem... elements)
      Calls the addAll method on the ObservableList returned by the Menu#getItems() method.
      Returns:
      builder instance
    • addItems

      public final MenuBuilder addItems(Collection<? extends MenuItem> col)
      Calls the addAll method on the ObservableList returned by the Menu#getItems() method.
      Returns:
      builder instance
    • withItems

      public static MenuBuilder withItems(MenuItem... elements)
      Creates an instance of the builder, then calls the addAll method on the ObservableList returned by the Menu#getItems() method.
      Returns:
      builder instance
    • withItems

      public static MenuBuilder withItems(Collection<? extends MenuItem> col)
      Creates an instance of the builder, then calls the addAll method on the ObservableList returned by the Menu#getItems() method.
      Returns:
      builder instance
    • addStyleClass

      public final MenuBuilder addStyleClass(String... elements)
      Calls the addAll method on the ObservableList returned by the Menu#getStyleClass() method.
      Returns:
      builder instance
    • addStyleClass

      public final MenuBuilder addStyleClass(Collection<? extends String> col)
      Calls the addAll method on the ObservableList returned by the Menu#getStyleClass() method.
      Returns:
      builder instance
    • acceleratorPropertyApply

      public MenuBuilder acceleratorPropertyApply(Consumer<ObjectProperty<KeyCombination>> op)
      Applies a function to the acceleratorProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.acceleratorProperty().bind(anotherProperty))
      
      // Use shorthand form
      .acceleratorPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • disablePropertyApply

      public MenuBuilder disablePropertyApply(Consumer<BooleanProperty> op)
      Applies a function to the disableProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.disableProperty().bind(anotherProperty))
      
      // Use shorthand form
      .disablePropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • graphicPropertyApply

      public MenuBuilder graphicPropertyApply(Consumer<ObjectProperty<Node>> op)
      Applies a function to the graphicProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.graphicProperty().bind(anotherProperty))
      
      // Use shorthand form
      .graphicPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • idPropertyApply

      public MenuBuilder idPropertyApply(Consumer<StringProperty> op)
      Applies a function to the idProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.idProperty().bind(anotherProperty))
      
      // Use shorthand form
      .idPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • mnemonicParsingPropertyApply

      public MenuBuilder mnemonicParsingPropertyApply(Consumer<BooleanProperty> op)
      Applies a function to the mnemonicParsingProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.mnemonicParsingProperty().bind(anotherProperty))
      
      // Use shorthand form
      .mnemonicParsingPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • onActionPropertyApply

      public MenuBuilder onActionPropertyApply(Consumer<ObjectProperty<EventHandler<ActionEvent>>> op)
      Applies a function to the onActionProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.onActionProperty().bind(anotherProperty))
      
      // Use shorthand form
      .onActionPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • onHiddenPropertyApply

      public MenuBuilder onHiddenPropertyApply(Consumer<ObjectProperty<EventHandler<Event>>> op)
      Applies a function to the onHiddenProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.onHiddenProperty().bind(anotherProperty))
      
      // Use shorthand form
      .onHiddenPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • onHidingPropertyApply

      public MenuBuilder onHidingPropertyApply(Consumer<ObjectProperty<EventHandler<Event>>> op)
      Applies a function to the onHidingProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.onHidingProperty().bind(anotherProperty))
      
      // Use shorthand form
      .onHidingPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • onMenuValidationPropertyApply

      public MenuBuilder onMenuValidationPropertyApply(Consumer<ObjectProperty<EventHandler<Event>>> op)
      Applies a function to the onMenuValidationProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.onMenuValidationProperty().bind(anotherProperty))
      
      // Use shorthand form
      .onMenuValidationPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • onShowingPropertyApply

      public MenuBuilder onShowingPropertyApply(Consumer<ObjectProperty<EventHandler<Event>>> op)
      Applies a function to the onShowingProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.onShowingProperty().bind(anotherProperty))
      
      // Use shorthand form
      .onShowingPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • onShownPropertyApply

      public MenuBuilder onShownPropertyApply(Consumer<ObjectProperty<EventHandler<Event>>> op)
      Applies a function to the onShownProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.onShownProperty().bind(anotherProperty))
      
      // Use shorthand form
      .onShownPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • parentMenuPropertyApply

      public MenuBuilder parentMenuPropertyApply(Consumer<ReadOnlyObjectProperty<Menu>> op)
      Applies a function to the parentMenuProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.parentMenuProperty().bind(anotherProperty))
      
      // Use shorthand form
      .parentMenuPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • parentPopupPropertyApply

      public MenuBuilder parentPopupPropertyApply(Consumer<ReadOnlyObjectProperty<ContextMenu>> op)
      Applies a function to the parentPopupProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.parentPopupProperty().bind(anotherProperty))
      
      // Use shorthand form
      .parentPopupPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • showingPropertyApply

      public MenuBuilder showingPropertyApply(Consumer<ReadOnlyBooleanProperty> op)
      Applies a function to the showingProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.showingProperty().bind(anotherProperty))
      
      // Use shorthand form
      .showingPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • stylePropertyApply

      public MenuBuilder stylePropertyApply(Consumer<StringProperty> op)
      Applies a function to the styleProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.styleProperty().bind(anotherProperty))
      
      // Use shorthand form
      .stylePropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • textPropertyApply

      public MenuBuilder textPropertyApply(Consumer<StringProperty> op)
      Applies a function to the textProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.textProperty().bind(anotherProperty))
      
      // Use shorthand form
      .textPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • visiblePropertyApply

      public MenuBuilder visiblePropertyApply(Consumer<BooleanProperty> op)
      Applies a function to the visibleProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.visibleProperty().bind(anotherProperty))
      
      // Use shorthand form
      .visiblePropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance