scalafx.scene.control

Alert

class Alert extends Dialog[javafx.scene.control.ButtonType] with SFXDelegate[javafx.scene.control.Alert]

The Alert class subclasses the Dialog class, and provides support for a number of pre-built dialog types that can be easily shown to users to prompt for a response.

Wraps a JavaFX Alert.

Example of displaying an information dialog:

new Alert(AlertType.Information) {
  title = "Information Dialog"
  headerText = "Look, an Information Dialog"
  contentText = "I have a great message for you!"
}.showAndWait()

A bit more elaborated example that is using a custom buttons:

val One = new ButtonType("One")
val Two = new ButtonType("Two")
val Three = new ButtonType("Three")

val alert = new Alert(AlertType.Confirmation) {
  title = "Confirmation Dialog with Custom Actions"
  headerText = "Look, a Confirmation Dialog with Custom Actions"
  contentText = "Choose your option."
  buttonTypes = Seq(One, Two, Three, ButtonType.Cancel)
}

val result = alert.showAndWait()
result match {
  case Some(One)   => println("... user chose \"One\"")
  case Some(Two)   => println("... user chose \"Two\"")
  case Some(Three) => println("... user chose \"Three\"")
  case _           => println("... user chose CANCEL or closed the dialog")
}
Source
Alert.scala
Linear Supertypes
Dialog[javafx.scene.control.ButtonType], EventTarget, SFXDelegate[javafx.scene.control.Alert], AnyRef, Any
Type Hierarchy Learn more about scaladoc diagrams
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Alert
  2. Dialog
  3. EventTarget
  4. SFXDelegate
  5. AnyRef
  6. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Alert(alertType: AlertType, contentText: String, buttons: ButtonType*)

    Creates an alert with the given contentText, ButtonTypes, and AlertType (refer to the AlertType documentation for clarification over which one is most appropriate).

    Creates an alert with the given contentText, ButtonTypes, and AlertType (refer to the AlertType documentation for clarification over which one is most appropriate).

    By passing in a variable number of ButtonType arguments, the developer is directly overriding the default buttons that will be displayed in the dialog, replacing the pre-defined buttons with whatever is specified in the varargs array.

    By passing in an AlertType, default values for the title property, headerText property, graphic property properties are set. Once the Alert is instantiated, developers are able to modify the values of the alert as desired.

  2. new Alert(alertType: AlertType)

    Creates an alert with the given AlertType (refer to the AlertType documentation for clarification over which one is most appropriate).

    Creates an alert with the given AlertType (refer to the AlertType documentation for clarification over which one is most appropriate).

    By passing in an AlertType, default values for the title property, headerText property, graphic property properties are set. Once the Alert is instantiated, developers are able to modify the values of the alert as desired.

  3. new Alert(delegate: javafx.scene.control.Alert)

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def alertType: ObjectProperty[AlertType]

  7. def alertType_=(v: AlertType): Unit

  8. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  9. def buildEventDispatchChain(tail: EventDispatchChain): EventDispatchChain

    Construct an event dispatch chain for this target.

    Construct an event dispatch chain for this target. The event dispatch chain contains event dispatchers which might be interested in processing of events targeted at this EventTarget. This event target is not automatically added to the chain, so if it wants to process events, it needs to add an EventDispatcher for itself to the chain.

    In the case the event target is part of some hierarchy, the chain for it is usually built from event dispatchers collected from the root of the hierarchy to the event target.

    The event dispatch chain is constructed by modifications to the provided initial event dispatch chain. The returned chain should have the initial chain at its end so the dispatchers should be prepended to the initial chain.

    The caller shouldn't assume that the initial chain remains unchanged nor that the returned value will reference a different chain.

    tail

    the initial chain to build from

    returns

    the resulting event dispatch chain for this target

    Definition Classes
    EventTarget
    See also

    Original Documentation.

  10. def buttonTypes: ObservableBuffer[javafx.scene.control.ButtonType]

    Returns an ObservableBuffer of all ButtonType instances that are currently set inside this Alert instance.

  11. def buttonTypes_=(types: Iterable[ButtonType]): Unit

  12. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  13. def contentText: StringProperty

    A property representing the content text for the dialog pane.

    A property representing the content text for the dialog pane. The content text is lower precedence than the scalafx.scene.control.DialogPane.content node, meaning that if both the content node and the contentText properties are set, the content text will not be displayed in a default DialogPane instance.

    Definition Classes
    Dialog
    See also

    Original Documentation.

  14. def contentText_=(value: String): Unit

    Definition Classes
    Dialog
  15. val delegate: javafx.scene.control.Alert

    JavaFX object to be wrapped.

    JavaFX object to be wrapped.

    Definition Classes
    AlertDialogEventTargetSFXDelegate
  16. def dialogPane: ObjectProperty[javafx.scene.control.DialogPane]

    Definition Classes
    Dialog
  17. def dialogPane_=(value: DialogPane): Unit

    Definition Classes
    Dialog
  18. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  19. def equals(ref: Any): Boolean

    Verifies if a object is equals to this delegate.

    Verifies if a object is equals to this delegate.

    ref

    Object to be compared.

    returns

    if the other object is equals to this delegate or not.

    Definition Classes
    SFXDelegate → AnyRef → Any
  20. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  21. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  22. def graphic: ObjectProperty[javafx.scene.Node]

    The dialog graphic, presented either in the header, if one is showing, or to the left of the content.

    The dialog graphic, presented either in the header, if one is showing, or to the left of the content.

    Definition Classes
    Dialog
    See also

    Original Documentation.

  23. def graphic_=(value: Node): Unit

    Definition Classes
    Dialog
  24. def hashCode(): Int

    returns

    The delegate hashcode

    Definition Classes
    SFXDelegate → AnyRef → Any
  25. def headerText: StringProperty

    A property representing the header text for the dialog pane.

    A property representing the header text for the dialog pane. The header text is lower precedence than the scalafx.scene.control.DialogPane.header node, meaning that if both the header node and the headerText properties are set, the header text will not be displayed in a default DialogPane instance.

    Definition Classes
    Dialog
    See also

    Original Documentation.

  26. def headerText_=(value: Option[String]): Unit

    Definition Classes
    Dialog
  27. def headerText_=(value: String): Unit

    Definition Classes
    Dialog
  28. def height: ReadOnlyDoubleProperty

    Property representing the height of the dialog.

    Property representing the height of the dialog.

    Definition Classes
    Dialog
  29. def height_=(h: Double): Unit

    Definition Classes
    Dialog
  30. def initModality(modality: Modality): Unit

    Specifies the modality for this dialog.

    Specifies the modality for this dialog. This must be done prior to making the dialog visible. The modality is one of: Modality.NONE, Modality.WINDOW_MODAL, or Modality.APPLICATION_MODAL.

    modality

    the modality for this dialog.

    Definition Classes
    Dialog
    Exceptions thrown
    IllegalStateException

    if this property is set after the dialog has ever been made visible.

  31. def initOwner(window: Window): Unit

    Specifies the owner Window for this dialog, or null for a top-level, unowned dialog.

    Specifies the owner Window for this dialog, or null for a top-level, unowned dialog. This must be done prior to making the dialog visible.

    window

    the owner Window for this dialog.

    Definition Classes
    Dialog
    Exceptions thrown
    IllegalStateException

    if this property is set after the dialog has ever been made visible.

  32. def initStyle(style: StageStyle): Unit

    Specifies the style for this dialog.

    Specifies the style for this dialog. This must be done prior to making the dialog visible. The style is one of: StageStyle.DECORATED, StageStyle.UNDECORATED, StageStyle.TRANSPARENT, StageStyle.UTILITY, or StageStyle.UNIFIED.

    style

    the style for this dialog.

    Definition Classes
    Dialog
    Exceptions thrown
    IllegalStateException

    if this property is set after the dialog has ever been made visible.

  33. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  34. def modality: Modality

    Retrieves the modality attribute for this dialog.

    Retrieves the modality attribute for this dialog.

    returns

    the modality.

    Definition Classes
    Dialog
    See also

    getModality Original Documentation.

  35. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  36. final def notify(): Unit

    Definition Classes
    AnyRef
  37. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  38. def onCloseRequest: ObjectProperty[EventHandler[javafx.scene.control.DialogEvent]]

    Definition Classes
    Dialog
  39. def onCloseRequest_=(v: EventHandler[javafx.scene.control.DialogEvent]): Unit

    Definition Classes
    Dialog
  40. def onHidden: ObjectProperty[EventHandler[javafx.scene.control.DialogEvent]]

    Called just after the Dialog has been hidden.

    Called just after the Dialog has been hidden. When the scalafx.scene.control.Dialog is hidden, this event handler is invoked allowing the developer to clean up resources or perform other tasks when the scalafx.scene.control.Dialog is closed.

    Definition Classes
    Dialog
  41. def onHidden_=(v: EventHandler[javafx.scene.control.DialogEvent]): Unit

    Definition Classes
    Dialog
  42. def onHiding: ObjectProperty[EventHandler[javafx.scene.control.DialogEvent]]

    Called just prior to the Dialog being hidden.

    Called just prior to the Dialog being hidden.

    Definition Classes
    Dialog
  43. def onHiding_=(v: EventHandler[javafx.scene.control.DialogEvent]): Unit

    Definition Classes
    Dialog
  44. def onShowing: ObjectProperty[EventHandler[javafx.scene.control.DialogEvent]]

    Called just prior to the Dialog being shown.

    Called just prior to the Dialog being shown.

    Definition Classes
    Dialog
  45. def onShowing_=(v: EventHandler[javafx.scene.control.DialogEvent]): Unit

    Definition Classes
    Dialog
  46. def onShown: ObjectProperty[EventHandler[javafx.scene.control.DialogEvent]]

    Called just after the Dialog is shown.

    Called just after the Dialog is shown.

    Definition Classes
    Dialog
  47. def onShown_=(v: EventHandler[javafx.scene.control.DialogEvent]): Unit

    Definition Classes
    Dialog
  48. def owner: Window

    Retrieves the owner Window for this dialog, or null for an unowned dialog.

    Retrieves the owner Window for this dialog, or null for an unowned dialog.

    returns

    the owner Window.

    Definition Classes
    Dialog
    See also

    Original Documentation.

  49. def resizable: BooleanProperty

    Represents whether the dialog is resizable.

    Represents whether the dialog is resizable.

    Definition Classes
    Dialog
  50. def resizable_=(v: Boolean): Unit

    Definition Classes
    Dialog
  51. def result: ObjectProperty[javafx.scene.control.ButtonType]

    A property representing what has been returned from the dialog.

    A property representing what has been returned from the dialog. A result is generated through the resultConverter, which is intended to convert from the ButtonType that the user clicked on into a value of type R.

    Definition Classes
    Dialog
    See also

    Original Documentation.

  52. def resultConverter: ObjectProperty[(ButtonType) ⇒ javafx.scene.control.ButtonType]

    API to convert the scalafx.scene.control.ButtonType that the user clicked on into a result that can be returned via the scalafx.scene.control.Dialog.result property.

    API to convert the scalafx.scene.control.ButtonType that the user clicked on into a result that can be returned via the scalafx.scene.control.Dialog.result property. This is necessary as scalafx.scene.control.ButtonType represents the visual button within the dialog, and do not know how to map themselves to a valid result - that is a requirement of the dialog implementation by making use of the result converter. In some cases, the result type of a Dialog subclass is ButtonType (which means that the result converter can be null), but in some cases (where the result type, R, is not ButtonType or Void), this callback must be specified.

    Definition Classes
    Dialog
  53. def resultConverter_=(f: (ButtonType) ⇒ javafx.scene.control.ButtonType): Unit

    Definition Classes
    Dialog
  54. def result_=(value: javafx.scene.control.ButtonType): Unit

    Definition Classes
    Dialog
  55. def showAndWait(): Option[ButtonType]

    Shows the dialog and waits for the user response (in other words, brings up a blocking dialog, with the returned value the users input).

    Shows the dialog and waits for the user response (in other words, brings up a blocking dialog, with the returned value the users input).

    dialog.showAndWait()

    Or when return value is required:

    val r = dialog.showAndWait()
    r match {
      case Some(v) => ...
      case None    => ...
    }
    returns

    An Option that contains the result.

  56. def showAndWait[F](j2s: F = x: R => x)(implicit convert: DConvert[javafx.scene.control.ButtonType, F]): Option[S]

    Shows the dialog and waits for the user response (in other words, brings up a blocking dialog, with the returned value the users input).

    Shows the dialog and waits for the user response (in other words, brings up a blocking dialog, with the returned value the users input).

    The intended use when return value is ignored:

    dialog.showAndWait()

    Or when return value is required:

    val r = dialog.showAndWait()
    r match {
      case Some(v) => ...
      case None => ...
    }
    returns

    An Option that contains the result.

    Definition Classes
    Dialog
    See also

    showAndWait Original Documentation.

  57. def showing: ReadOnlyBooleanProperty

    Represents whether the dialog is currently showing.

    Represents whether the dialog is currently showing.

    Definition Classes
    Dialog
  58. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  59. def title: StringProperty

    Return the title of the dialog.

    Return the title of the dialog.

    Definition Classes
    Dialog
  60. def title_=(v: String): Unit

    Definition Classes
    Dialog
  61. def toString(): String

    returns

    Returns the original delegate's toString() adding a [SFX] prefix.

    Definition Classes
    SFXDelegate → AnyRef → Any
  62. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  63. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  64. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  65. def width: ReadOnlyDoubleProperty

    Property representing the width of the dialog.

    Property representing the width of the dialog.

    Definition Classes
    Dialog
  66. def width_=(w: Double): Unit

    Definition Classes
    Dialog
  67. def x: ReadOnlyDoubleProperty

    The horizontal location of this scalafx.scene.control.Dialog.

    The horizontal location of this scalafx.scene.control.Dialog. Changing this attribute will move the scalafx.scene.control.Dialog horizontally.

    Definition Classes
    Dialog
  68. def x_=(v: Double): Unit

    Definition Classes
    Dialog
  69. def y: ReadOnlyDoubleProperty

    The vertical location of this scalafx.scene.control.Dialog.

    The vertical location of this scalafx.scene.control.Dialog. Changing this attribute will move the scalafx.scene.control.Dialog vertically.

    Definition Classes
    Dialog
  70. def y_=(v: Double): Unit

    Definition Classes
    Dialog

Inherited from Dialog[javafx.scene.control.ButtonType]

Inherited from EventTarget

Inherited from SFXDelegate[javafx.scene.control.Alert]

Inherited from AnyRef

Inherited from Any

Ungrouped