Class AlertBuilder
AlertBuilder
class constructs instances of the Alert
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 Alert
constructor
and returns an instance of the AlertBuilder
.
You can use method chaining to call the builder methods for configuring the Alert
.
Finally, invoke the build
method to generate an instance of the Alert
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 Summary
Modifier and TypeMethodDescriptionfinal AlertBuilder
addButtonTypes
(Collection<? extends ButtonType> col) Calls theaddAll
method on the ObservableList returned by theAlert#getButtonTypes()
method.final AlertBuilder
addButtonTypes
(ButtonType... elements) Calls theaddAll
method on the ObservableList returned by theAlert#getButtonTypes()
method.alertType
(Alert.AlertType alertType) A builder method that invokes thesetAlertType
method on the instance being constructed.Applies a function to thealertTypeProperty
of the instance being constructed.Applies a function to the Alert instance being constructed.build()
Builds and returns an instance of theAlert
class.contentText
(String contentText) A builder method that invokes thesetContentText
method on the instance being constructed.Applies a function to thecontentTextProperty
of the instance being constructed.static AlertBuilder
create
(Alert.AlertType alertType) Accepts the constructor arguments ofAlert(Alert.AlertType)
and returns an instance ofAlertBuilder
.static AlertBuilder
create
(Alert.AlertType alertType, String contentText, ButtonType... buttons) Accepts the constructor arguments ofAlert(Alert.AlertType, String, ButtonType...)
and returns an instance ofAlertBuilder
.dialogPane
(DialogPane value) A builder method that invokes thesetDialogPane
method on the instance being constructed.Applies a function to thedialogPaneProperty
of the instance being constructed.A builder method that invokes thesetGraphic
method on the instance being constructed.Applies a function to thegraphicProperty
of the instance being constructed.headerText
(String headerText) A builder method that invokes thesetHeaderText
method on the instance being constructed.Applies a function to theheaderTextProperty
of the instance being constructed.height
(double height) A builder method that invokes thesetHeight
method on the instance being constructed.Applies a function to theheightProperty
of the instance being constructed.onCloseRequest
(EventHandler<DialogEvent> value) A builder method that invokes thesetOnCloseRequest
method on the instance being constructed.Applies a function to theonCloseRequestProperty
of the instance being constructed.onHidden
(EventHandler<DialogEvent> value) A builder method that invokes thesetOnHidden
method on the instance being constructed.Applies a function to theonHiddenProperty
of the instance being constructed.onHiding
(EventHandler<DialogEvent> value) A builder method that invokes thesetOnHiding
method on the instance being constructed.Applies a function to theonHidingProperty
of the instance being constructed.onShowing
(EventHandler<DialogEvent> value) A builder method that invokes thesetOnShowing
method on the instance being constructed.Applies a function to theonShowingProperty
of the instance being constructed.onShown
(EventHandler<DialogEvent> value) A builder method that invokes thesetOnShown
method on the instance being constructed.Applies a function to theonShownProperty
of the instance being constructed.resizable
(boolean resizable) A builder method that invokes thesetResizable
method on the instance being constructed.Applies a function to theresizableProperty
of the instance being constructed.result
(ButtonType value) A builder method that invokes thesetResult
method on the instance being constructed.resultConverter
(Callback<ButtonType, ButtonType> value) A builder method that invokes thesetResultConverter
method on the instance being constructed.Applies a function to theresultConverterProperty
of the instance being constructed.Applies a function to theresultProperty
of the instance being constructed.Applies a function to theshowingProperty
of the instance being constructed.A builder method that invokes thesetTitle
method on the instance being constructed.Applies a function to thetitleProperty
of the instance being constructed.width
(double width) A builder method that invokes thesetWidth
method on the instance being constructed.Applies a function to thewidthProperty
of the instance being constructed.static AlertBuilder
withButtonTypes
(Collection<? extends ButtonType> col) Creates an instance of the builder, then calls thesetAll(Collection<? extends ButtonType> col
method on the ObservableList returned by theAlert#getButtonTypes()
method.static AlertBuilder
withButtonTypes
(ButtonType... elements) Creates an instance of the builder, then calls theaddAll(ButtonType... elements)
method on the ObservableList returned by theAlert#getButtonTypes()
method.x
(double x) A builder method that invokes thesetX
method on the instance being constructed.Applies a function to thexProperty
of the instance being constructed.y
(double y) A builder method that invokes thesetY
method on the instance being constructed.Applies a function to theyProperty
of the instance being constructed.
-
Method Details
-
create
Accepts the constructor arguments ofAlert(Alert.AlertType)
and returns an instance ofAlertBuilder
.- Returns:
- an instance of the
AlertBuilder
.
-
create
public static AlertBuilder create(Alert.AlertType alertType, String contentText, ButtonType... buttons) Accepts the constructor arguments ofAlert(Alert.AlertType, String, ButtonType...)
and returns an instance ofAlertBuilder
.- Returns:
- an instance of the
AlertBuilder
.
-
build
Builds and returns an instance of theAlert
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
Alert
class
-
apply
Applies a function to the Alert instance being constructed. Most operations on the instance can be performed using this method.- Returns:
- builder instance
-
alertType
A builder method that invokes thesetAlertType
method on the instance being constructed.- Returns:
- builder instance
-
contentText
A builder method that invokes thesetContentText
method on the instance being constructed.- Returns:
- builder instance
-
dialogPane
A builder method that invokes thesetDialogPane
method on the instance being constructed.- Returns:
- builder instance
-
graphic
A builder method that invokes thesetGraphic
method on the instance being constructed.- Returns:
- builder instance
-
headerText
A builder method that invokes thesetHeaderText
method on the instance being constructed.- Returns:
- builder instance
-
height
A builder method that invokes thesetHeight
method on the instance being constructed.- Returns:
- builder instance
-
onCloseRequest
A builder method that invokes thesetOnCloseRequest
method on the instance being constructed.- Returns:
- builder instance
-
onHidden
A builder method that invokes thesetOnHidden
method on the instance being constructed.- Returns:
- builder instance
-
onHiding
A builder method that invokes thesetOnHiding
method on the instance being constructed.- Returns:
- builder instance
-
onShowing
A builder method that invokes thesetOnShowing
method on the instance being constructed.- Returns:
- builder instance
-
onShown
A builder method that invokes thesetOnShown
method on the instance being constructed.- Returns:
- builder instance
-
resizable
A builder method that invokes thesetResizable
method on the instance being constructed.- Returns:
- builder instance
-
result
A builder method that invokes thesetResult
method on the instance being constructed.- Returns:
- builder instance
-
resultConverter
A builder method that invokes thesetResultConverter
method on the instance being constructed.- Returns:
- builder instance
-
title
A builder method that invokes thesetTitle
method on the instance being constructed.- Returns:
- builder instance
-
width
A builder method that invokes thesetWidth
method on the instance being constructed.- Returns:
- builder instance
-
x
A builder method that invokes thesetX
method on the instance being constructed.- Returns:
- builder instance
-
y
A builder method that invokes thesetY
method on the instance being constructed.- Returns:
- builder instance
-
addButtonTypes
Calls theaddAll
method on the ObservableList returned by theAlert#getButtonTypes()
method.- Returns:
- builder instance
-
addButtonTypes
Calls theaddAll
method on the ObservableList returned by theAlert#getButtonTypes()
method.- Returns:
- builder instance
-
alertTypePropertyApply
Applies a function to thealertTypeProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.alertTypeProperty().bind(anotherProperty)) // Use shorthand form .alertTypePropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
contentTextPropertyApply
Applies a function to thecontentTextProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.contentTextProperty().bind(anotherProperty)) // Use shorthand form .contentTextPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
dialogPanePropertyApply
Applies a function to thedialogPaneProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.dialogPaneProperty().bind(anotherProperty)) // Use shorthand form .dialogPanePropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
graphicPropertyApply
Applies a function to thegraphicProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.graphicProperty().bind(anotherProperty)) // Use shorthand form .graphicPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
headerTextPropertyApply
Applies a function to theheaderTextProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.headerTextProperty().bind(anotherProperty)) // Use shorthand form .headerTextPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
heightPropertyApply
Applies a function to theheightProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.heightProperty().bind(anotherProperty)) // Use shorthand form .heightPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
onCloseRequestPropertyApply
public AlertBuilder onCloseRequestPropertyApply(Consumer<ObjectProperty<EventHandler<DialogEvent>>> op) Applies a function to theonCloseRequestProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.onCloseRequestProperty().bind(anotherProperty)) // Use shorthand form .onCloseRequestPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
onHiddenPropertyApply
Applies a function to theonHiddenProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.onHiddenProperty().bind(anotherProperty)) // Use shorthand form .onHiddenPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
onHidingPropertyApply
Applies a function to theonHidingProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.onHidingProperty().bind(anotherProperty)) // Use shorthand form .onHidingPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
onShowingPropertyApply
Applies a function to theonShowingProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.onShowingProperty().bind(anotherProperty)) // Use shorthand form .onShowingPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
onShownPropertyApply
Applies a function to theonShownProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.onShownProperty().bind(anotherProperty)) // Use shorthand form .onShownPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
resizablePropertyApply
Applies a function to theresizableProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.resizableProperty().bind(anotherProperty)) // Use shorthand form .resizablePropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
resultConverterPropertyApply
public AlertBuilder resultConverterPropertyApply(Consumer<ObjectProperty<Callback<ButtonType, ButtonType>>> op) Applies a function to theresultConverterProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.resultConverterProperty().bind(anotherProperty)) // Use shorthand form .resultConverterPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
resultPropertyApply
Applies a function to theresultProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.resultProperty().bind(anotherProperty)) // Use shorthand form .resultPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
showingPropertyApply
Applies a function to theshowingProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.showingProperty().bind(anotherProperty)) // Use shorthand form .showingPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
titlePropertyApply
Applies a function to thetitleProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.titleProperty().bind(anotherProperty)) // Use shorthand form .titlePropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
widthPropertyApply
Applies a function to thewidthProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.widthProperty().bind(anotherProperty)) // Use shorthand form .widthPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
xPropertyApply
Applies a function to thexProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.xProperty().bind(anotherProperty)) // Use shorthand form .xPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
yPropertyApply
Applies a function to theyProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.yProperty().bind(anotherProperty)) // Use shorthand form .yPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
withButtonTypes
Creates an instance of the builder, then calls theaddAll(ButtonType... elements)
method on the ObservableList returned by theAlert#getButtonTypes()
method.After calling this method, you may need to invoke the
alertType(AlertType)
method. If you do not, the defaultAlertType.NONE
will be set.- Returns:
- builder instance
-
withButtonTypes
Creates an instance of the builder, then calls thesetAll(Collection<? extends ButtonType> col
method on the ObservableList returned by theAlert#getButtonTypes()
method.After calling this method, you may need to invoke the
alertType(AlertType)
method. If you do not, the defaultAlertType.NONE
will be set.- Returns:
- builder instance
-