Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: Alert

[13:7] extends: FxObj

Wraps JavaFX Alert, a pre-built dialog for displaying informational, warning, confirmation, or error messages with standard button responses. The alert type (INFORMATION, WARNING, CONFIRMATION, ERROR, or NONE) controls the icon and default buttons shown. Optional title, header, and content text can be set before displaying. Call showAndWait() to block until the user responds, or show() to display the dialog without blocking.

Methods

  • Alert (string AlertType = "INFORMATION", string Text = "")

    Creates a new Alert with the specified type and optional content text.

    • @p AlertType is a string: INFORMATION, WARNING, CONFIRMATION, ERROR, or NONE.
    • @p Text is an optional string with content text.
  • setTitle (string Title)

    Sets the dialog title.

    • @p Title is a string with the title.
    • @r this object for chaining
  • setHeaderText (string Text)

    Sets the header text.

    • @p Text is a string with the header, or null for none.
    • @r this object for chaining
  • setContentText (string Text)

    Sets the content text.

    • @p Text is a string with the content.
    • @r this object for chaining
  • showAndWait ()

    Shows the dialog and waits for the user to close it.

    • @r The result of the dialog.
  • setGraphic (object GraphicNode)

    Sets a graphic node displayed in the dialog header area.

    • @p GraphicNode is a Node object to use as the header graphic.
    • @r this object for chaining
  • getResult ()

    Returns the ButtonType that was clicked to close the dialog after showAndWait.

    • @r A ButtonType object representing the button the user clicked.
  • addButton (string ButtonType)

    Adds a custom button to the alert dialog.

    • @p ButtonType is a string matching a ButtonType constant name, e.g., OK or CANCEL.
    • @r this object for chaining
  • getDialogPane ()

    Returns the DialogPane of this alert, which contains the layout and buttons.

    • @r A DialogPane object with the alert's dialog pane.
  • show ()

    Shows the dialog without blocking.

    • @r this object for chaining