Class ChoiceDialogBuilder<T>

java.lang.Object
io.github.sosuisen.jfxbuilder.controls.ChoiceDialogBuilder<T>

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

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

      @SafeVarargs public static <T> ChoiceDialogBuilder<T> create(T defaultChoice, T... choices)
      Accepts the constructor arguments of ChoiceDialog(T, T...) and returns an instance of ChoiceDialogBuilder<T>.
      Returns:
      an instance of the ChoiceDialogBuilder<T>.
    • create

      public static <T> ChoiceDialogBuilder<T> create(T defaultChoice, Collection<T> choices)
      Accepts the constructor arguments of ChoiceDialog(T, Collection) and returns an instance of ChoiceDialogBuilder<T>.
      Returns:
      an instance of the ChoiceDialogBuilder<T>.
    • build

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

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

      public ChoiceDialogBuilder<T> contentText(String contentText)
      A builder method that invokes the setContentText method on the instance being constructed.
      Returns:
      builder instance
    • dialogPane

      public ChoiceDialogBuilder<T> dialogPane(DialogPane value)
      A builder method that invokes the setDialogPane method on the instance being constructed.
      Returns:
      builder instance
    • graphic

      public ChoiceDialogBuilder<T> graphic(Node graphic)
      A builder method that invokes the setGraphic method on the instance being constructed.
      Returns:
      builder instance
    • headerText

      public ChoiceDialogBuilder<T> headerText(String headerText)
      A builder method that invokes the setHeaderText method on the instance being constructed.
      Returns:
      builder instance
    • height

      public ChoiceDialogBuilder<T> height(double height)
      A builder method that invokes the setHeight method on the instance being constructed.
      Returns:
      builder instance
    • onCloseRequest

      public ChoiceDialogBuilder<T> onCloseRequest(EventHandler<DialogEvent> value)
      A builder method that invokes the setOnCloseRequest method on the instance being constructed.
      Returns:
      builder instance
    • onHidden

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

      public ChoiceDialogBuilder<T> onHiding(EventHandler<DialogEvent> value)
      A builder method that invokes the setOnHiding method on the instance being constructed.
      Returns:
      builder instance
    • onShowing

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

      public ChoiceDialogBuilder<T> onShown(EventHandler<DialogEvent> value)
      A builder method that invokes the setOnShown method on the instance being constructed.
      Returns:
      builder instance
    • resizable

      public ChoiceDialogBuilder<T> resizable(boolean resizable)
      A builder method that invokes the setResizable method on the instance being constructed.
      Returns:
      builder instance
    • result

      public ChoiceDialogBuilder<T> result(T value)
      A builder method that invokes the setResult method on the instance being constructed.
      Returns:
      builder instance
    • resultConverter

      public ChoiceDialogBuilder<T> resultConverter(Callback<ButtonType, T> value)
      A builder method that invokes the setResultConverter method on the instance being constructed.
      Returns:
      builder instance
    • selectedItem

      public ChoiceDialogBuilder<T> selectedItem(T item)
      A builder method that invokes the setSelectedItem method on the instance being constructed.
      Returns:
      builder instance
    • title

      public ChoiceDialogBuilder<T> title(String title)
      A builder method that invokes the setTitle method on the instance being constructed.
      Returns:
      builder instance
    • width

      public ChoiceDialogBuilder<T> width(double width)
      A builder method that invokes the setWidth method on the instance being constructed.
      Returns:
      builder instance
    • x

      public ChoiceDialogBuilder<T> x(double x)
      A builder method that invokes the setX method on the instance being constructed.
      Returns:
      builder instance
    • y

      public ChoiceDialogBuilder<T> y(double y)
      A builder method that invokes the setY method on the instance being constructed.
      Returns:
      builder instance
    • addItems

      @SafeVarargs public final ChoiceDialogBuilder<T> addItems(T... elements)
      Calls the addAll method on the ObservableList returned by the ChoiceDialog#getItems() method.
      Returns:
      builder instance
    • addItems

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

      @SafeVarargs public static <T> ChoiceDialogBuilder<T> withItems(T... elements)
      Creates an instance of the builder, then calls the addAll method on the ObservableList returned by the ChoiceDialog#getItems() method.
      Returns:
      builder instance
    • withItems

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

      public ChoiceDialogBuilder<T> contentTextPropertyApply(Consumer<StringProperty> op)
      Applies a function to the contentTextProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.contentTextProperty().bind(anotherProperty))
      
      // Use shorthand form
      .contentTextPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • dialogPanePropertyApply

      public ChoiceDialogBuilder<T> dialogPanePropertyApply(Consumer<ObjectProperty<DialogPane>> op)
      Applies a function to the dialogPaneProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

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

      public ChoiceDialogBuilder<T> 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
    • headerTextPropertyApply

      public ChoiceDialogBuilder<T> headerTextPropertyApply(Consumer<StringProperty> op)
      Applies a function to the headerTextProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.headerTextProperty().bind(anotherProperty))
      
      // Use shorthand form
      .headerTextPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • heightPropertyApply

      public ChoiceDialogBuilder<T> heightPropertyApply(Consumer<ReadOnlyDoubleProperty> op)
      Applies a function to the heightProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.heightProperty().bind(anotherProperty))
      
      // Use shorthand form
      .heightPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • onCloseRequestPropertyApply

      public ChoiceDialogBuilder<T> onCloseRequestPropertyApply(Consumer<ObjectProperty<EventHandler<DialogEvent>>> op)
      Applies a function to the onCloseRequestProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

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

      public ChoiceDialogBuilder<T> onHiddenPropertyApply(Consumer<ObjectProperty<EventHandler<DialogEvent>>> 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 ChoiceDialogBuilder<T> onHidingPropertyApply(Consumer<ObjectProperty<EventHandler<DialogEvent>>> 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
    • onShowingPropertyApply

      public ChoiceDialogBuilder<T> onShowingPropertyApply(Consumer<ObjectProperty<EventHandler<DialogEvent>>> 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 ChoiceDialogBuilder<T> onShownPropertyApply(Consumer<ObjectProperty<EventHandler<DialogEvent>>> 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
    • resizablePropertyApply

      public ChoiceDialogBuilder<T> resizablePropertyApply(Consumer<BooleanProperty> op)
      Applies a function to the resizableProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.resizableProperty().bind(anotherProperty))
      
      // Use shorthand form
      .resizablePropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • resultConverterPropertyApply

      public ChoiceDialogBuilder<T> resultConverterPropertyApply(Consumer<ObjectProperty<Callback<ButtonType, T>>> op)
      Applies a function to the resultConverterProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.resultConverterProperty().bind(anotherProperty))
      
      // Use shorthand form
      .resultConverterPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • resultPropertyApply

      public ChoiceDialogBuilder<T> resultPropertyApply(Consumer<ObjectProperty<T>> op)
      Applies a function to the resultProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.resultProperty().bind(anotherProperty))
      
      // Use shorthand form
      .resultPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • selectedItemPropertyApply

      public ChoiceDialogBuilder<T> selectedItemPropertyApply(Consumer<ReadOnlyObjectProperty<T>> op)
      Applies a function to the selectedItemProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

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

      public ChoiceDialogBuilder<T> 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
    • titlePropertyApply

      public ChoiceDialogBuilder<T> titlePropertyApply(Consumer<StringProperty> op)
      Applies a function to the titleProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.titleProperty().bind(anotherProperty))
      
      // Use shorthand form
      .titlePropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • widthPropertyApply

      public ChoiceDialogBuilder<T> widthPropertyApply(Consumer<ReadOnlyDoubleProperty> op)
      Applies a function to the widthProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.widthProperty().bind(anotherProperty))
      
      // Use shorthand form
      .widthPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • xPropertyApply

      public ChoiceDialogBuilder<T> xPropertyApply(Consumer<ReadOnlyDoubleProperty> op)
      Applies a function to the xProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.xProperty().bind(anotherProperty))
      
      // Use shorthand form
      .xPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • yPropertyApply

      public ChoiceDialogBuilder<T> yPropertyApply(Consumer<ReadOnlyDoubleProperty> op)
      Applies a function to the yProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

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