Module FXDialogs

Class AlertDialog.Builder

java.lang.Object
com.amirali.fxdialogs.AlertDialog.Builder
Enclosing class:
AlertDialog

public static class AlertDialog.Builder extends Object
AlertDialog builder
  • Constructor Details

    • Builder

      public Builder()
      create initial layout
  • Method Details

    • setDialogTitle

      public AlertDialog.Builder setDialogTitle(@NotNull @NotNull String title)
      sets title of the AlertDialog
      Parameters:
      title - title of the AlertDialog
      Returns:
      Builder
    • setDialogMessage

      public AlertDialog.Builder setDialogMessage(@NotNull @NotNull String message)
      sets message of the AlertDialog
      Parameters:
      message - message of the AlertDialog
      Returns:
      Builder
    • setPositiveButton

      public AlertDialog.Builder setPositiveButton(@NotNull @NotNull String text, @NotNull DialogInterface.OnClickListener listener)
      creates the positive button
      Parameters:
      text - text of the button
      listener - button onClickListener, when the button is clicked, the dialog closes
      Returns:
      Builder
    • setNegativeButton

      public AlertDialog.Builder setNegativeButton(@NotNull @NotNull String text, @NotNull DialogInterface.OnClickListener listener)
      creates the negative button
      Parameters:
      text - text of the button
      listener - button onClickListener, when the button is clicked, the dialog closes
      Returns:
      Builder
    • setNaturalButton

      public AlertDialog.Builder setNaturalButton(@NotNull @NotNull String text, @NotNull DialogInterface.OnClickListener listener)
      creates the natural button on the left side of the button bar
      Parameters:
      text - text of the button
      listener - button onClickListener, when the button is clicked, the dialog closes
      Returns:
      Builder
    • addStyles

      public AlertDialog.Builder addStyles(String... styles)
      adds styles to style list and that list will be added to the scene
      Parameters:
      styles - dialog styles
      Returns:
      Builder
    • setSingleChoiceItems

      public AlertDialog.Builder setSingleChoiceItems(@NotNull @NotNull String[] items, int selectedIndex, @NotNull DialogInterface.OnSingleChoiceSelectedListener listener)
      creates and adds RadioButton according to the items passed
      Parameters:
      items - RadioButtons texts
      selectedIndex - default selected RadioButton
      listener - selected listener
      Returns:
      Builder
    • setSingleChoiceItems

      public AlertDialog.Builder setSingleChoiceItems(@NotNull @NotNull String[] items, @NotNull DialogInterface.OnSingleChoiceSelectedListener listener)
      creates and adds RadioButton according to the items passed without default selected item
      Parameters:
      items - RadioButtons texts
      listener - selected listener
      Returns:
      Builder
    • setMultiChoiceItems

      public AlertDialog.Builder setMultiChoiceItems(@NotNull @NotNull String[] items, @NotNull @NotNull Integer[] selectedIndexes, @NotNull DialogInterface.OnMultiChoiceSelectedListener listener)
      creates and adds CheckBoxes according to the items passed
      Parameters:
      items - CheckBoxes texts
      selectedIndexes - default selected items
      listener - selected listener
      Returns:
      Builder
    • setMultiChoiceItems

      public AlertDialog.Builder setMultiChoiceItems(@NotNull @NotNull String[] items, @NotNull DialogInterface.OnMultiChoiceSelectedListener listener)
      creates and adds CheckBoxes according to the items passed without default selected items
      Parameters:
      items - CheckBoxes texts
      listener - selected listener
      Returns:
      Builder
    • setNode

      public AlertDialog.Builder setNode(@NotNull @NotNull javafx.scene.Node node)
      sets the custom node to the center of the dialog
      Parameters:
      node - custom node
      Returns:
      Builder
    • setSound

      public AlertDialog.Builder setSound(@NotNull @NotNull Sounds sound)
      sets the notification sound from Sounds and plays when stage is shown
      Note: You need to add javafx.media dependency to use sounds
      Parameters:
      sound - default notification sounds
      Returns:
      Builder
    • setSound

      public AlertDialog.Builder setSound(@NotNull @NotNull String path)
      sets the notification sound from custom file path and plays when stage is shown
      Note: You need to add javafx.media dependency to use sounds
      Parameters:
      path - custom file path
      Returns:
      Builder
    • create

      public AlertDialog create()
      creates AlertDialog
      Returns:
      AlertDialog