Class AlertDialog

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class AlertDialog extends GObject

Collects the arguments that are needed to present a message to the user.

The message is shown with the choose(Window, Cancellable, AsyncReadyCallback) function.

If you don't need to wait for a button to be clicked, you can use show(Window).

Since:
4.10
  • Constructor Details

    • AlertDialog

      public AlertDialog(MemorySegment address)
      Create a AlertDialog instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • AlertDialog

      public AlertDialog(String format, Object... varargs)

      Creates a new GtkAlertDialog object.

      The message will be set to the formatted string resulting from the arguments.

      Parameters:
      format - printf()-style format string
      varargs - arguments for format
      Since:
      4.10
    • AlertDialog

      public AlertDialog()
      Create a new AlertDialog.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the AlertDialog class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected AlertDialog asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • choose

      public void choose(@Nullable Window parent, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Shows the alert to the user.

      It is ok to pass NULL for the callback if the alert does not have more than one button. A simpler API for this case is show(Window).

      Parameters:
      parent - the parent window
      cancellable - a cancellable to cancel the operation
      callback - a callback to call when the operation is complete
      Since:
      4.10
    • chooseFinish

      public int chooseFinish(AsyncResult result) throws GErrorException
      Parameters:
      result - the result
      Returns:
      the index of the button that was clicked, or -1 if the dialog was cancelled and Gtk.AlertDialog:cancel-button is not set
      Throws:
      GErrorException - see GError
      Since:
      4.10
    • getButtons

      public @Nullable String @Nullable [] getButtons()
      Returns the button labels for the alert.
      Returns:
      the button labels
      Since:
      4.10
    • getCancelButton

      public int getCancelButton()
      Returns the index of the cancel button.
      Returns:
      the index of the cancel button, or -1
      Since:
      4.10
    • getDefaultButton

      public int getDefaultButton()
      Returns the index of the default button.
      Returns:
      the index of the default button, or -1
      Since:
      4.10
    • getDetail

      public String getDetail()
      Returns the detail text that will be shown in the alert.
      Returns:
      the detail text
      Since:
      4.10
    • getMessage

      public String getMessage()
      Returns the message that will be shown in the alert.
      Returns:
      the message
      Since:
      4.10
    • getModal

      public boolean getModal()
      Returns whether the alert blocks interaction with the parent window while it is presented.
      Returns:
      true if the alert is modal
      Since:
      4.10
    • setButtons

      public void setButtons(@Nullable String @Nullable [] labels)
      Sets the button labels for the alert.
      Parameters:
      labels - the new button labels
      Since:
      4.10
    • setCancelButton

      public void setCancelButton(int button)

      Sets the index of the cancel button.

      See Gtk.AlertDialog:cancel-button for details of how this value is used.

      Parameters:
      button - the new cancel button
      Since:
      4.10
    • setDefaultButton

      public void setDefaultButton(int button)

      Sets the index of the default button.

      See Gtk.AlertDialog:default-button for details of how this value is used.

      Parameters:
      button - the new default button
      Since:
      4.10
    • setDetail

      public void setDetail(String detail)
      Sets the detail text that will be shown in the alert.
      Parameters:
      detail - the new detail text
      Since:
      4.10
    • setMessage

      public void setMessage(String message)
      Sets the message that will be shown in the alert.
      Parameters:
      message - the new message
      Since:
      4.10
    • setModal

      public void setModal(boolean modal)
      Sets whether the alert blocks interaction with the parent window while it is presented.
      Parameters:
      modal - the new value
      Since:
      4.10
    • show

      public void show(@Nullable Window parent)

      Shows the alert to the user.

      This function is a simpler version of choose(Window, Cancellable, AsyncReadyCallback) intended for dialogs with a single button.

      If you want to cancel the dialog or if the alert has more than one button, you should use that function instead and provide it with a Cancellable and callback respectively.

      Parameters:
      parent - the parent window
      Since:
      4.10
    • builder

      public static AlertDialog.Builder<? extends AlertDialog.Builder> builder()
      A AlertDialog.Builder object constructs a AlertDialog with the specified properties. Use the various set...() methods to set properties, and finish construction with AlertDialog.Builder.build().
      Returns:
      the builder object