public class Wizard
extends java.lang.Object
The API for creating multi-page Wizards, based on JavaFX Dialog API.
Wizard can be setup in following few steps:
WizardPaneWizard.FlowFor simple, linear wizards, the Wizard.LinearFlow can be used.
It is a flow based on a collection of wizard pages. Here is the example:
// Create pages. Here for simplicity we just create and instance of WizardPane.
WizardPane page1 = new WizardPane();
WizardPane page2 = new WizardPane();
WizardPane page3 = new WizardPane();
// create wizard
Wizard wizard = new Wizard();
// create and assign the flow
wizard.setFlow(new LinearFlow(page1, page2, page3));
// show wizard and wait for response
wizard.showAndWait().ifPresent(result -> {
if (result == ButtonType.FINISH) {
System.out.println("Wizard finished, settings: " + wizard.getSettings());
}
});
For more complex wizard flows we suggest to create a custom ones, describing page traversal logic. Here is a simplified example:
Wizard.Flow branchingFlow = new Wizard.Flow() {
public Optional<WizardPane> advance(WizardPane currentPage) {
return Optional.of(getNext(currentPage));
}
public boolean canAdvance(WizardPane currentPage) {
return currentPage != page3;
}
private WizardPane getNext(WizardPane currentPage) {
if ( currentPage == null ) {
return page1;
} else if ( currentPage == page1) {
// skipNextPage() does not exist - this just represents that you
// can add a conditional statement here to change the page.
return page1.skipNextPage()? page3: page2;
} else {
return page3;
}
}
};| Type | Property and Description |
|---|---|
javafx.beans.property.ObjectProperty<Wizard.Flow> |
flow
The
Wizard.Flow property represents the flow of pages in the wizard. |
javafx.beans.property.BooleanProperty |
invalid
Property for overriding the individual validation state of this
Wizard. |
javafx.beans.property.BooleanProperty |
readSettings
Property for overriding the individual read-settings state of this
Wizard. |
javafx.beans.property.ObjectProperty<javafx.scene.control.ButtonType> |
result |
javafx.beans.property.StringProperty |
title
Return the titleProperty of the wizard.
|
| Modifier and Type | Class and Description |
|---|---|
static interface |
Wizard.Flow
Represents the page flow of the wizard.
|
static class |
Wizard.LinearFlow
LinearFlow is an implementation of the
Wizard.Flow interface,
designed to support the most common type of wizard flow - namely, a linear
wizard page flow (i.e. |
| Constructor and Description |
|---|
Wizard()
Creates an instance of the wizard without an owner.
|
Wizard(java.lang.Object owner)
Creates an instance of the wizard with the given owner.
|
Wizard(java.lang.Object owner,
java.lang.String title)
Creates an instance of the wizard with the given owner and title.
|
| Modifier and Type | Method and Description |
|---|---|
javafx.beans.property.ObjectProperty<Wizard.Flow> |
flowProperty()
The
Wizard.Flow property represents the flow of pages in the wizard. |
Wizard.Flow |
getFlow()
Returns the currently set
Wizard.Flow, which represents the flow of
pages in the wizard. |
javafx.collections.ObservableMap<java.lang.Object,java.lang.Object> |
getProperties()
Returns an observable map of properties on this Wizard for use primarily
by application developers - not to be confused with the
getSettings() map that represents the values entered by the user
into the wizard. |
javafx.collections.ObservableMap<java.lang.String,java.lang.Object> |
getSettings()
The settings map is the place where all data from pages is kept once the
user moves on from the page, assuming there is a
ValueExtractor
that is capable of extracting a value out of the various fields on the page. |
java.lang.String |
getTitle()
Return the title of the wizard.
|
java.lang.Object |
getUserData()
Returns a previously set Object property, or null if no such property
has been set using the
setUserData(Object) method. |
boolean |
hasProperties()
Tests if this Wizard has properties.
|
javafx.beans.property.BooleanProperty |
invalidProperty()
Property for overriding the individual validation state of this
Wizard. |
boolean |
isInvalid()
Gets the value of the property
invalid. |
boolean |
isReadSettings()
Gets the value of the property
readSettings. |
javafx.beans.property.BooleanProperty |
readSettingsProperty()
Property for overriding the individual read-settings state of this
Wizard. |
javafx.beans.property.ObjectProperty<javafx.scene.control.ButtonType> |
resultProperty() |
void |
setFlow(Wizard.Flow flow)
Sets the
Wizard.Flow, which represents the flow of pages in the wizard. |
void |
setInvalid(boolean invalid)
Sets the value of the property
invalid. |
void |
setReadSettings(boolean readSettings)
Sets the value of the property
readSettings. |
void |
setTitle(java.lang.String title)
Change the Title of the wizard.
|
void |
setUserData(java.lang.Object value)
Convenience method for setting a single Object property that can be
retrieved at a later date.
|
java.util.Optional<javafx.scene.control.ButtonType> |
showAndWait()
Shows the wizard and waits for the user response (in other words, brings
up a blocking dialog, with the returned value the users input).
|
javafx.beans.property.StringProperty |
titleProperty()
Return the titleProperty of the wizard.
|
public final javafx.beans.property.ObjectProperty<javafx.scene.control.ButtonType> resultProperty
public final javafx.beans.property.StringProperty titleProperty
getTitle(),
setTitle(String)public final javafx.beans.property.ObjectProperty<Wizard.Flow> flowProperty
Wizard.Flow property represents the flow of pages in the wizard.getFlow(),
setFlow(Flow)public final javafx.beans.property.BooleanProperty invalidProperty
Wizard.
Setting invalid to true will disable the next/finish Button and the user
will not be able to advance to the next page of the Wizard. Setting
invalid to false will enable the next/finish Button. ValidationSupport.invalidProperty() of a
page and bind it to the invalid property: wizard.invalidProperty().bind(page.validationSupport.invalidProperty());
isInvalid(),
setInvalid(boolean)public final javafx.beans.property.BooleanProperty readSettingsProperty
Wizard.
Setting readSettings to true will enable the value extraction for this
Wizard. Setting readSettings to false will disable the value
extraction for this Wizard.isReadSettings(),
setReadSettings(boolean)public Wizard()
public Wizard(java.lang.Object owner)
owner - The object from which the owner window is deduced (typically
this is a Node, but it may also be a Scene or a Stage).public Wizard(java.lang.Object owner,
java.lang.String title)
owner - The object from which the owner window is deduced (typically
this is a Node, but it may also be a Scene or a Stage).title - The wizard title.public final java.util.Optional<javafx.scene.control.ButtonType> showAndWait()
Optional that contains the result.public final javafx.beans.property.ObjectProperty<javafx.scene.control.ButtonType> resultProperty()
public final javafx.collections.ObservableMap<java.lang.String,java.lang.Object> getSettings()
ValueExtractor
that is capable of extracting a value out of the various fields on the page.public final javafx.beans.property.StringProperty titleProperty()
getTitle(),
setTitle(String)public final java.lang.String getTitle()
public final void setTitle(java.lang.String title)
title - public final javafx.beans.property.ObjectProperty<Wizard.Flow> flowProperty()
Wizard.Flow property represents the flow of pages in the wizard.getFlow(),
setFlow(Flow)public final Wizard.Flow getFlow()
Wizard.Flow, which represents the flow of
pages in the wizard.public final void setFlow(Wizard.Flow flow)
Wizard.Flow, which represents the flow of pages in the wizard.public final javafx.collections.ObservableMap<java.lang.Object,java.lang.Object> getProperties()
getSettings() map that represents the values entered by the user
into the wizard.public boolean hasProperties()
public void setUserData(java.lang.Object value)
getUserData().value - The value to be stored - this can later be retrieved by calling
getUserData().public java.lang.Object getUserData()
setUserData(Object) method.public final void setInvalid(boolean invalid)
invalid.invalid - The new validation state
invalidProperty()public final boolean isInvalid()
invalid.invalidProperty()public final javafx.beans.property.BooleanProperty invalidProperty()
Wizard.
Setting invalid to true will disable the next/finish Button and the user
will not be able to advance to the next page of the Wizard. Setting
invalid to false will enable the next/finish Button. ValidationSupport.invalidProperty() of a
page and bind it to the invalid property: wizard.invalidProperty().bind(page.validationSupport.invalidProperty());
isInvalid(),
setInvalid(boolean)public final void setReadSettings(boolean readSettings)
readSettings.readSettings - The new read-settings statereadSettingsProperty()public final boolean isReadSettings()
readSettings.readSettingsProperty()public final javafx.beans.property.BooleanProperty readSettingsProperty()
Wizard.
Setting readSettings to true will enable the value extraction for this
Wizard. Setting readSettings to false will disable the value
extraction for this Wizard.isReadSettings(),
setReadSettings(boolean)