The API for creating multi-page Wizards, based on JavaFX Dialog API.
Wizard can be setup in following few steps:
WizardPaneWizard.Flow 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;
}
}
};
| Modifier and Type | Class and Description |
|---|---|
| public static interface | Wizard.
Represents the page flow of the wizard. |
| public static class | Wizard.
LinearFlow is an implementation of the |
| Modifier and Type | Field and Description |
|---|---|
| private final EventHandler | |
| private final EventHandler | |
| private final ButtonType | |
| private final EventHandler | |
| private final ButtonType | |
| private final EventHandler | |
| private Optional | |
| private Dialog | dialog
Private fields |
| private ObjectProperty | |
| private final BooleanProperty | |
| private final Stack | |
| private ObservableMap | |
| private final BooleanProperty | |
| private int | |
| private final ObservableMap | |
| private final StringProperty | |
| private static final Object |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| private static void | |
| private boolean | |
| public final ObjectProperty | |
| public final Dialog | |
| public final Wizard. | |
| public final ObservableMap | Returns: an observable map of properties on this Wizard for use primarily by application developersReturns an observable map of properties on this Wizard for use primarily
by application developers - not to be confused with the
|
| public final ObservableMap | 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 |
| public final String | |
| public Object | Returns: The Object that was previously set, or null if no property has been set or if null was set.Returns a previously set Object property, or null if no such property
has been set using the |
| public boolean | |
| public final BooleanProperty | Returns: The validation state propertyProperty for overriding the individual validation state of this |
| public final boolean | |
| public final boolean | |
| private boolean | |
| private void | |
| public final BooleanProperty | Returns: The readSettings state propertyProperty for overriding the individual read-settings state of this |
| public final ObjectProperty | |
| public final void | |
| public final void | setInvalid(boolean
The new validation state
invalid)invalidProperty()Sets the value of the property |
| public final void | setReadSettings(boolean
The new read-settings state readSettings)Sets the value of the property |
| public final void | |
| public void | setUserData(Object
The value to be stored - this can later be retrieved by calling
value)getUserData().Convenience method for setting a single Object property that can be retrieved at a later date. |
| public final Optional | Returns: AnOptional that contains the result.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 | |
| private void | updatePage(Dialog<ButtonType> dialog, Optional<WizardPane> nextPage, boolean advancing)
Private implementation |
| private void | |
| private void |
| BUTTON_CANCEL_ACTION_HANDLER | back to summary |
|---|---|
| private final EventHandler<ActionEvent> BUTTON_CANCEL_ACTION_HANDLER | |
| BUTTON_FINISH_ACTION_HANDLER | back to summary |
|---|---|
| private final EventHandler<ActionEvent> BUTTON_FINISH_ACTION_HANDLER | |
| BUTTON_NEXT | back to summary |
|---|---|
| private final ButtonType BUTTON_NEXT | |
| BUTTON_NEXT_ACTION_HANDLER | back to summary |
|---|---|
| private final EventHandler<ActionEvent> BUTTON_NEXT_ACTION_HANDLER | |
| BUTTON_PREVIOUS | back to summary |
|---|---|
| private final ButtonType BUTTON_PREVIOUS | |
| BUTTON_PREVIOUS_ACTION_HANDLER | back to summary |
|---|---|
| private final EventHandler<ActionEvent> BUTTON_PREVIOUS_ACTION_HANDLER | |
| currentPage | back to summary |
|---|---|
| private Optional<WizardPane> currentPage | |
| dialog | back to summary |
|---|---|
| private Dialog<ButtonType> dialog Private fields | |
| flow | back to summary |
|---|---|
| private ObjectProperty<Wizard. The | |
| invalidProperty | back to summary |
|---|---|
| private final BooleanProperty invalidProperty | |
| pageHistory | back to summary |
|---|---|
| private final Stack<WizardPane> pageHistory | |
| properties | back to summary |
|---|---|
| private ObservableMap<Object, Object> properties | |
| readSettingsProperty | back to summary |
|---|---|
| private final BooleanProperty readSettingsProperty | |
| settingCounter | back to summary |
|---|---|
| private int settingCounter | |
| settings | back to summary |
|---|---|
| private final ObservableMap<String, Object> settings | |
| titleProperty | back to summary |
|---|---|
| private final StringProperty titleProperty | |
| USER_DATA_KEY | back to summary |
|---|---|
| private static final Object USER_DATA_KEY | |
| Wizard | back to summary |
|---|---|
| public Wizard() Creates an instance of the wizard without an owner. | |
| Wizard | back to summary |
|---|---|
| public Wizard(Object owner) Creates an instance of the wizard with the given owner.
| |
| Wizard | back to summary |
|---|---|
| public Wizard(Object owner, String title) Creates an instance of the wizard with the given owner and title. | |
| addButtonIfMissing | back to summary |
|---|---|
| private static void addButtonIfMissing(WizardPane page, ButtonType buttonType, EventHandler<ActionEvent> actionHandler) | |
| checkNode | back to summary |
|---|---|
| private boolean checkNode(Node n) | |
| flowProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| getDialog | back to summary |
|---|---|
| public final Dialog Provides access to the
| |
| getFlow | back to summary |
|---|---|
| public final Wizard. Returns the currently set | |
| getProperties | back to summary |
|---|---|
| public final ObservableMap Returns an observable map of properties on this Wizard for use primarily
by application developers - not to be confused with the
| |
| getSettings | back to summary |
|---|---|
| public final ObservableMap 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 | |
| getTitle | back to summary |
|---|---|
| public final String getTitle() Return the title of the wizard. | |
| getUserData | back to summary |
|---|---|
| public Object getUserData() Returns a previously set Object property, or null if no such property
has been set using the
| |
| hasProperties | back to summary |
|---|---|
| public boolean hasProperties() Tests if this Wizard has properties.
| |
| invalidProperty | back to summary |
|---|---|
| public final BooleanProperty invalidProperty() Property for overriding the individual validation state of this
| |
| isInvalid | back to summary |
|---|---|
| public final boolean isInvalid() Gets the value of the property
| |
| isReadSettings | back to summary |
|---|---|
| public final boolean isReadSettings() Gets the value of the property
| |
| readSetting | back to summary |
|---|---|
| private boolean readSetting(Node n) | |
| readSettings | back to summary |
|---|---|
| private void readSettings(WizardPane page) | |
| readSettingsProperty | back to summary |
|---|---|
| public final BooleanProperty readSettingsProperty() Property for overriding the individual read-settings state of this
| |
| resultProperty | back to summary |
|---|---|
public final ObjectProperty
| |
| setFlow | back to summary |
|---|---|
| public final void setFlow(Wizard. Sets the | |
| setInvalid | back to summary |
|---|---|
| public final void setInvalid(boolean invalid) Sets the value of the property
| |
| setReadSettings | back to summary |
|---|---|
| public final void setReadSettings(boolean readSettings) Sets the value of the property
| |
| setTitle | back to summary |
|---|---|
| public final void setTitle(String title) Change the Title of the wizard. | |
| setUserData | back 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
| |
| showAndWait | back to summary |
|---|---|
| public final Optional Shows the wizard and waits for the user response (in other words, brings up a blocking dialog, with the returned value the users input).
| |
| titleProperty | back to summary |
|---|---|
| public final StringProperty titleProperty() Return the titleProperty of the wizard. | |
| updatePage | back to summary |
|---|---|
| private void updatePage(Dialog<ButtonType> dialog, Optional<WizardPane> nextPage, boolean advancing) Private implementation | |
| validateActionState | back to summary |
|---|---|
| private void validateActionState() | |
| validateButton | back to summary |
|---|---|
| private void validateButton(ButtonType buttonType, BooleanSupplier condition) | |
| Modifier and Type | Method and Description |
|---|---|
| public Optional | Returns: Optional value containing the next wizard page.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.The current wizard page currentPage)Check if advancing to the next page is possible |
| advance | back to summary |
|---|---|
| public Optional Advances the wizard to the next page if possible.
| |
| canAdvance | back to summary |
|---|---|
| public boolean canAdvance(WizardPane currentPage) Check if advancing to the next page is possible
| |
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
Wizard, WizardPane
| Modifier and Type | Field and Description |
|---|---|
| private final List |
| Access | Constructor and Description |
|---|---|
| public | LinearFlow(Collection<WizardPane> pages)
Creates a new LinearFlow instance that will allow for stepping through
the given collection of |
| public | LinearFlow(WizardPane... pages)
Creates a new LinearFlow instance that will allow for stepping through
the given varargs array of |
| Modifier and Type | Method and Description |
|---|---|
| public Optional | advance(WizardPane currentPage)
Implements org. Advances the wizard to the next page if possible. |
| public boolean | canAdvance(WizardPane currentPage)
Implements org. Check if advancing to the next page is possible |
| pages | back to summary |
|---|---|
| private final List<WizardPane> pages | |
| LinearFlow | back to summary |
|---|---|
| public LinearFlow(Collection<WizardPane> pages) Creates a new LinearFlow instance that will allow for stepping through
the given collection of | |
| LinearFlow | back to summary |
|---|---|
| public LinearFlow(WizardPane... pages) Creates a new LinearFlow instance that will allow for stepping through
the given varargs array of | |
| advance | back to summary |
|---|---|
| public Optional Implements org. Doc from org. Advances the wizard to the next page if possible.
| |
| canAdvance | back to summary |
|---|---|
| public boolean canAdvance(WizardPane currentPage) Implements org. Doc from org. Check if advancing to the next page is possible
| |