Top Description Inners Fields Constructors Methods
org.controlsfx.dialog

public Class Wizard

extends Object
Class Inheritance
Static Imports
impl.org.controlsfx.i18n.Localization.asKey, .Localization.localize

The API for creating multi-page Wizards, based on JavaFX Dialog API.
Wizard can be setup in following few steps:

For simple, linear wizards, the 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;
        }
    }
};

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Wizard.Flow

Represents the page flow of the wizard.

public 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. through all pages in the order that they are specified).

Field Summary

Modifier and TypeField and Description
private final EventHandler<ActionEvent>
private final EventHandler<ActionEvent>
private final ButtonType
private final EventHandler<ActionEvent>
private final ButtonType
private final EventHandler<ActionEvent>
private Optional<WizardPane>
private Dialog<ButtonType>
dialog

Private fields

private ObjectProperty<Wizard.Flow>
flow

The Flow property represents the flow of pages in the wizard.

private final BooleanProperty
private final Stack<WizardPane>
private ObservableMap<Object, Object>
private final BooleanProperty
private int
private final ObservableMap<String, Object>
private final StringProperty
private static final Object

Constructor Summary

AccessConstructor and Description
public
Wizard()

Creates an instance of the wizard without an owner.

public
Wizard(Object
The object from which the owner window is deduced (typically this is a Node, but it may also be a Scene or a Stage).
owner
)

Creates an instance of the wizard with the given owner.

public
Wizard(Object
The object from which the owner window is deduced (typically this is a Node, but it may also be a Scene or a Stage).
owner
,
String
The wizard title.
title
)

Creates an instance of the wizard with the given owner and title.

Method Summary

Modifier and TypeMethod and Description
private static void
private boolean
public final ObjectProperty<Wizard.Flow>
public final Dialog<ButtonType>

Returns:

The Dialog representing this Wizard.
This can be accessed in order to modify its properties if necessary, for example setting its window icon or its modality.
getDialog
()

Provides access to the Dialog object used to display the Wizard.

public final Wizard.Flow
getFlow()

Returns the currently set Flow, which represents the flow of pages in the wizard.

public final ObservableMap<Object, Object>

Returns:

an observable map of properties on this Wizard for use primarily by application developers
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.

public final ObservableMap<String, 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.

public final String
getTitle()

Return the title of the wizard.

public Object

Returns:

The Object that was previously set, or null if no property has been set or if null was set.
getUserData
()

Returns a previously set Object property, or null if no such property has been set using the setUserData(Object) method.

public boolean

Returns:

true if this Wizard has properties.
hasProperties
()

Tests if this Wizard has properties.

public final BooleanProperty

Returns:

The validation state property
invalidProperty
()

Property for overriding the individual validation state of this Wizard.

public final boolean

Returns:

The validation state
isInvalid
()

Gets the value of the property invalid.

public final boolean

Returns:

The read-settings state
isReadSettings
()

Gets the value of the property readSettings.

private boolean
private void
public final BooleanProperty

Returns:

The readSettings state property
readSettingsProperty
()

Property for overriding the individual read-settings state of this Wizard.

public final ObjectProperty<ButtonType>
resultProperty()

Returns: Dialog#resultProperty() of the Dialog representing this Wizard.

public final void
setFlow(Wizard.Flow flow)

Sets the Flow, which represents the flow of pages in the wizard.

public final void
setInvalid(boolean
The new validation state invalidProperty()
invalid
)

Sets the value of the property invalid.

public final void
setReadSettings(boolean
The new read-settings state
readSettings
)

Sets the value of the property readSettings.

public final void
setTitle(String title)

Change the Title of the wizard.

public void
setUserData(Object
The value to be stored - this can later be retrieved by calling getUserData().
value
)

Convenience method for setting a single Object property that can be retrieved at a later date.

public final Optional<ButtonType>

Returns:

An Optional that contains the result.
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).

public final StringProperty
titleProperty()

Return the titleProperty of the wizard.

private void
updatePage(Dialog<ButtonType> dialog, Optional<WizardPane> nextPage, boolean advancing)

Private implementation

private void
private void
validateButton(ButtonType buttonType, BooleanSupplier condition)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BUTTON_CANCEL_ACTION_HANDLERback to summary
private final EventHandler<ActionEvent> BUTTON_CANCEL_ACTION_HANDLER
BUTTON_FINISH_ACTION_HANDLERback to summary
private final EventHandler<ActionEvent> BUTTON_FINISH_ACTION_HANDLER
BUTTON_NEXTback to summary
private final ButtonType BUTTON_NEXT
BUTTON_NEXT_ACTION_HANDLERback to summary
private final EventHandler<ActionEvent> BUTTON_NEXT_ACTION_HANDLER
BUTTON_PREVIOUSback to summary
private final ButtonType BUTTON_PREVIOUS
BUTTON_PREVIOUS_ACTION_HANDLERback to summary
private final EventHandler<ActionEvent> BUTTON_PREVIOUS_ACTION_HANDLER
currentPageback to summary
private Optional<WizardPane> currentPage
dialogback to summary
private Dialog<ButtonType> dialog

Private fields

flowback to summary
private ObjectProperty<Wizard.Flow> flow

The Flow property represents the flow of pages in the wizard.

invalidPropertyback to summary
private final BooleanProperty invalidProperty
pageHistoryback to summary
private final Stack<WizardPane> pageHistory
propertiesback to summary
private ObservableMap<Object, Object> properties
readSettingsPropertyback to summary
private final BooleanProperty readSettingsProperty
settingCounterback to summary
private int settingCounter
settingsback to summary
private final ObservableMap<String, Object> settings
titlePropertyback to summary
private final StringProperty titleProperty
USER_DATA_KEYback to summary
private static final Object USER_DATA_KEY

Constructor Detail

Wizardback to summary
public Wizard()

Creates an instance of the wizard without an owner.

Wizardback to summary
public Wizard(Object owner)

Creates an instance of the wizard with the given owner.

Parameters
owner:Object

The object from which the owner window is deduced (typically this is a Node, but it may also be a Scene or a Stage).

Wizardback to summary
public Wizard(Object owner, String title)

Creates an instance of the wizard with the given owner and title.

Parameters
owner:Object

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:String

The wizard title.

Method Detail

addButtonIfMissingback to summary
private static void addButtonIfMissing(WizardPane page, ButtonType buttonType, EventHandler<ActionEvent> actionHandler)
checkNodeback to summary
private boolean checkNode(Node n)
flowPropertyback to summary
public final ObjectProperty<Wizard.Flow> flowProperty()
getDialogback to summary
public final Dialog<ButtonType> getDialog()

Provides access to the Dialog object used to display the Wizard.

Returns:Dialog<ButtonType>

The Dialog representing this Wizard.
This can be accessed in order to modify its properties if necessary, for example setting its window icon or its modality.

getFlowback to summary
public final Wizard.Flow getFlow()

Returns the currently set Flow, which represents the flow of pages in the wizard.

getPropertiesback to summary
public final ObservableMap<Object, 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.

Returns:ObservableMap<Object, Object>

an observable map of properties on this Wizard for use primarily by application developers

getSettingsback to summary
public final ObservableMap<String, 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.

getTitleback to summary
public final String getTitle()

Return the title of the wizard.

getUserDataback to summary
public Object getUserData()

Returns a previously set Object property, or null if no such property has been set using the setUserData(Object) method.

Returns:Object

The Object that was previously set, or null if no property has been set or if null was set.

hasPropertiesback to summary
public boolean hasProperties()

Tests if this Wizard has properties.

Returns:boolean

true if this Wizard has properties.

invalidPropertyback to summary
public final BooleanProperty invalidProperty()

Property for overriding the individual validation state of this 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.

For example you can use the ValidationSupport#invalidProperty() of a page and bind it to the invalid property:
wizard.invalidProperty().bind(page.validationSupport.invalidProperty());

Returns:BooleanProperty

The validation state property

isInvalidback to summary
public final boolean isInvalid()

Gets the value of the property invalid.

Returns:boolean

The validation state

See Also
invalidProperty()
isReadSettingsback to summary
public final boolean isReadSettings()

Gets the value of the property readSettings.

Returns:boolean

The read-settings state

See Also
readSettingsProperty()
readSettingback to summary
private boolean readSetting(Node n)
readSettingsback to summary
private void readSettings(WizardPane page)
readSettingsPropertyback to summary
public final BooleanProperty readSettingsProperty()

Property for overriding the individual read-settings state of this 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.

Returns:BooleanProperty

The readSettings state property

resultPropertyback to summary
public final ObjectProperty<ButtonType> resultProperty()
Returns:ObjectProperty<ButtonType>

Dialog#resultProperty() of the Dialog representing this Wizard.

setFlowback to summary
public final void setFlow(Wizard.Flow flow)

Sets the Flow, which represents the flow of pages in the wizard.

setInvalidback to summary
public final void setInvalid(boolean invalid)

Sets the value of the property invalid.

Parameters
invalid:boolean

The new validation state invalidProperty()

setReadSettingsback to summary
public final void setReadSettings(boolean readSettings)

Sets the value of the property readSettings.

Parameters
readSettings:boolean

The new read-settings state

See Also
readSettingsProperty()
setTitleback to summary
public final void setTitle(String title)

Change the Title of the wizard.

setUserDataback to summary
public void setUserData(Object value)

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 calling getUserData().

Parameters
value:Object

The value to be stored - this can later be retrieved by calling getUserData().

showAndWaitback to summary
public final Optional<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).

Returns:Optional<ButtonType>

An Optional that contains the result.

titlePropertyback to summary
public final StringProperty titleProperty()

Return the titleProperty of the wizard.

updatePageback to summary
private void updatePage(Dialog<ButtonType> dialog, Optional<WizardPane> nextPage, boolean advancing)

Private implementation

validateActionStateback to summary
private void validateActionState()
validateButtonback to summary
private void validateButton(ButtonType buttonType, BooleanSupplier condition)
org.controlsfx.dialog back to summary

public Interface Wizard.Flow

Known Direct Implementers
org.controlsfx.dialog.Wizard.LinearFlow

Represents the page flow of the wizard. It defines only methods required to move forward in the wizard logic, as backward movement is automatically handled by wizard itself, using internal page history.

Method Summary

Modifier and TypeMethod and Description
public Optional<WizardPane>

Returns:

Optional value containing the next wizard page.
advance
(WizardPane
The current wizard page
currentPage
)

Advances the wizard to the next page if possible.

public boolean

Returns:

true if it is possible to advance to the next page, false otherwise.
canAdvance
(WizardPane
The current wizard page
currentPage
)

Check if advancing to the next page is possible

Method Detail

advanceback to summary
public Optional<WizardPane> advance(WizardPane currentPage)

Advances the wizard to the next page if possible.

Parameters
currentPage:WizardPane

The current wizard page

Returns:Optional<WizardPane>

Optional value containing the next wizard page.

canAdvanceback to summary
public boolean canAdvance(WizardPane currentPage)

Check if advancing to the next page is possible

Parameters
currentPage:WizardPane

The current wizard page

Returns:boolean

true if it is possible to advance to the next page, false otherwise.

org.controlsfx.dialog back to summary

public Class Wizard.LinearFlow

extends Object
implements Flow
Class Inheritance
All Implemented Interfaces
org.controlsfx.dialog.Wizard.Flow

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. through all pages in the order that they are specified). Therefore, this Flow implementation simply traverses a collections of WizardPanes.

For example of how to use this API, please refer to the Wizard documentation

See Also
Wizard, WizardPane

Field Summary

Modifier and TypeField and Description
private final List<WizardPane>

Constructor Summary

AccessConstructor and Description
public
LinearFlow(Collection<WizardPane> pages)

Creates a new LinearFlow instance that will allow for stepping through the given collection of WizardPane instances.

public
LinearFlow(WizardPane... pages)

Creates a new LinearFlow instance that will allow for stepping through the given varargs array of WizardPane instances.

Method Summary

Modifier and TypeMethod and Description
public Optional<WizardPane>
advance(WizardPane currentPage)

Implements org.controlsfx.dialog.Wizard.Flow.advance.

Advances the wizard to the next page if possible.

public boolean
canAdvance(WizardPane currentPage)

Implements org.controlsfx.dialog.Wizard.Flow.canAdvance.

Check if advancing to the next page is possible

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

pagesback to summary
private final List<WizardPane> pages

Constructor Detail

LinearFlowback to summary
public LinearFlow(Collection<WizardPane> pages)

Creates a new LinearFlow instance that will allow for stepping through the given collection of WizardPane instances.

LinearFlowback to summary
public LinearFlow(WizardPane... pages)

Creates a new LinearFlow instance that will allow for stepping through the given varargs array of WizardPane instances.

Method Detail

advanceback to summary
public Optional<WizardPane> advance(WizardPane currentPage)

Implements org.controlsfx.dialog.Wizard.Flow.advance.

Doc from org.controlsfx.dialog.Wizard.Flow.advance.

Advances the wizard to the next page if possible.

Annotations
@Override
canAdvanceback to summary
public boolean canAdvance(WizardPane currentPage)

Implements org.controlsfx.dialog.Wizard.Flow.canAdvance.

Doc from org.controlsfx.dialog.Wizard.Flow.canAdvance.

Check if advancing to the next page is possible

Annotations
@Override