java.lang.Object
org.controlsfx.dialog.Wizard
The API for creating multi-page Wizards, based on JavaFX Dialog API.
Wizard can be setup in following few steps:
- Design wizard pages by inheriting them from
WizardPane - Define wizard flow by implementing
Wizard.Flow - Create and instance of the Wizard and assign flow to it
- Execute the wizard using showAndWait method
- Values can be extracted from settings map by calling getSettings
For 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;
}
}
};-
Property Summary
PropertiesTypePropertyDescriptionfinal ObjectProperty<Wizard.Flow>TheWizard.Flowproperty represents the flow of pages in the wizard.final BooleanPropertyProperty for overriding the individual validation state of thisWizard.final BooleanPropertyProperty for overriding the individual read-settings state of thisWizard.final ObjectProperty<ButtonType>final StringPropertyReturn the titleProperty of the wizard. -
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceRepresents the page flow of the wizard.static classLinearFlow is an implementation of theWizard.Flowinterface, designed to support the most common type of wizard flow - namely, a linear wizard page flow (i.e. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal ObjectProperty<Wizard.Flow>TheWizard.Flowproperty represents the flow of pages in the wizard.final Dialog<ButtonType>final Wizard.FlowgetFlow()Returns the currently setWizard.Flow, which represents the flow of pages in the wizard.final ObservableMap<Object,Object> Returns an observable map of properties on this Wizard for use primarily by application developers - not to be confused with thegetSettings()map that represents the values entered by the user into the wizard.final ObservableMap<String,Object> The settings map is the place where all data from pages is kept once the user moves on from the page, assuming there is aValueExtractorthat is capable of extracting a value out of the various fields on the page.final StringgetTitle()Return the title of the wizard.Returns a previously set Object property, or null if no such property has been set using thesetUserData(Object)method.booleanTests if this Wizard has properties.final BooleanPropertyProperty for overriding the individual validation state of thisWizard.final booleanGets the value of the propertyinvalid.final booleanGets the value of the propertyreadSettings.final BooleanPropertyProperty for overriding the individual read-settings state of thisWizard.final ObjectProperty<ButtonType>final voidsetFlow(Wizard.Flow flow) Sets theWizard.Flow, which represents the flow of pages in the wizard.final voidsetInvalid(boolean invalid) Sets the value of the propertyinvalid.final voidsetReadSettings(boolean readSettings) Sets the value of the propertyreadSettings.final voidChange the Title of the wizard.voidsetUserData(Object value) Convenience method for setting a single Object property that can be retrieved at a later date.final Optional<ButtonType>Shows the wizard and waits for the user response (in other words, brings up a blocking dialog, with the returned value the users input).final StringPropertyReturn the titleProperty of the wizard.
-
Property Details
-
result
-
title
Return the titleProperty of the wizard.- See Also:
-
flow
TheWizard.Flowproperty represents the flow of pages in the wizard.- See Also:
-
invalid
Property for overriding the individual validation state of thisWizard. Settinginvalidto true will disable the next/finish Button and the user will not be able to advance to the next page of theWizard. Settinginvalidto false will enable the next/finish Button.
For example you can use theValidationSupport.invalidProperty()of a page and bind it to theinvalidproperty:
wizard.invalidProperty().bind(page.validationSupport.invalidProperty());- See Also:
-
readSettings
Property for overriding the individual read-settings state of thisWizard. SettingreadSettingsto true will enable the value extraction for thisWizard. SettingreadSettingsto false will disable the value extraction for thisWizard.- See Also:
-
-
Constructor Details
-
Wizard
public Wizard()Creates an instance of the wizard without an owner. -
Wizard
Creates an instance of the wizard with the given owner.- Parameters:
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).
-
Wizard
Creates an instance of the wizard with the given owner and title.- Parameters:
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.
-
-
Method Details
-
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).- Returns:
- An
Optionalthat contains the result.
-
resultProperty
-
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 aValueExtractorthat is capable of extracting a value out of the various fields on the page. -
getDialog
-
titleProperty
Return the titleProperty of the wizard.- See Also:
-
getTitle
Return the title of the wizard. -
setTitle
Change the Title of the wizard.- Parameters:
title-
-
flowProperty
TheWizard.Flowproperty represents the flow of pages in the wizard.- See Also:
-
getFlow
Returns the currently setWizard.Flow, which represents the flow of pages in the wizard. -
setFlow
Sets theWizard.Flow, which represents the flow of pages in the wizard. -
getProperties
Returns an observable map of properties on this Wizard for use primarily by application developers - not to be confused with thegetSettings()map that represents the values entered by the user into the wizard.- Returns:
- an observable map of properties on this Wizard for use primarily by application developers
-
hasProperties
public boolean hasProperties()Tests if this Wizard has properties.- Returns:
- true if this Wizard has properties.
-
setUserData
Convenience method for setting a single Object property that can be retrieved at a later date. This is functionally equivalent to calling the getProperties().put(Object key, Object value) method. This can later be retrieved by callinggetUserData().- Parameters:
value- The value to be stored - this can later be retrieved by callinggetUserData().
-
getUserData
Returns a previously set Object property, or null if no such property has been set using thesetUserData(Object)method.- Returns:
- The Object that was previously set, or null if no property has been set or if null was set.
-
setInvalid
public final void setInvalid(boolean invalid) Sets the value of the propertyinvalid.- Parameters:
invalid- The new validation stateinvalidProperty()
-
isInvalid
public final boolean isInvalid()Gets the value of the propertyinvalid.- Returns:
- The validation state
- See Also:
-
invalidProperty
Property for overriding the individual validation state of thisWizard. Settinginvalidto true will disable the next/finish Button and the user will not be able to advance to the next page of theWizard. Settinginvalidto false will enable the next/finish Button.
For example you can use theValidationSupport.invalidProperty()of a page and bind it to theinvalidproperty:
wizard.invalidProperty().bind(page.validationSupport.invalidProperty());- See Also:
-
setReadSettings
public final void setReadSettings(boolean readSettings) Sets the value of the propertyreadSettings.- Parameters:
readSettings- The new read-settings state- See Also:
-
isReadSettings
public final boolean isReadSettings()Gets the value of the propertyreadSettings.- Returns:
- The read-settings state
- See Also:
-
readSettingsProperty
Property for overriding the individual read-settings state of thisWizard. SettingreadSettingsto true will enable the value extraction for thisWizard. SettingreadSettingsto false will disable the value extraction for thisWizard.- See Also:
-