Class MenuItemBuilder

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

public class MenuItemBuilder extends Object
The MenuItemBuilder class constructs instances of the MenuItem 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 MenuItem constructor and returns an instance of the MenuItemBuilder.

You can use method chaining to call the builder methods for configuring the MenuItem. Finally, invoke the build method to generate an instance of the MenuItem 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 MenuItemBuilder create()
      Returns an instance of the MenuItemBuilder.
      Returns:
      an instance of the MenuItemBuilder.
    • create

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

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

      public MenuItem build()
      Builds and returns an instance of the MenuItem 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 MenuItem class
    • apply

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      public MenuItemBuilder 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 MenuItemBuilder 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 MenuItemBuilder 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 MenuItemBuilder 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 MenuItemBuilder 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 MenuItemBuilder 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
    • onMenuValidationPropertyApply

      public MenuItemBuilder 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
    • parentMenuPropertyApply

      public MenuItemBuilder 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 MenuItemBuilder 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
    • stylePropertyApply

      public MenuItemBuilder 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 MenuItemBuilder 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 MenuItemBuilder 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