Is there any example how to create wizard in JavaFX?
For example to setup a program or for configuration. Can this be done with simple code or I need to create custom component?
Is there any example how to create wizard in JavaFX?
For example to setup a program or for configuration. Can this be done with simple code or I need to create custom component?
Here's my solution, using ControlsFX
Wizard
classes, and FXML, with a non-modal wizard.WizardView.fxml:
NB: Would be better to use a
Wizard
instead of anAnchor
, but this would requireLinearFlow
being a public type, which is not the case by now (it's an inner class ofWizard
in Java 1.8.0_144).WizardController.java:
Application class:
}
Here is code for a sample wizard in JavaFX.
This code was a JavaFX 2.x conversion of a SWT based solution for java2s.
You could modify this code to use ControlsFX dialogs to get a more professional look to the wizard.
Update
This code was updated to use some JavaFX 8 features.
Suggestions for further enhancements
ControlsFX Wizard
The Wizard implementation in the 3rd party ControlsFX library implements some of the suggested enhancements detailed above, so, for many people will be a better solution for a production quality application than the simple example outlined in this answer.
DataFX 2 has a flow API to design wizards, for example. You can define a flow through a list / map of views and share a data model. For more information see this presentation: http://de.slideshare.net/HendrikEbbers/datafx-javaone-2013
Using the http://fxexperience.com/controlsfx/ library the following code works for me. It uses fxml files for each wizard page. The helper function runWizard then loads the resources and creates pages from it. Of course you can modifiy the content as outlined in ControlsFX 8.20.7 Wizard examples - getting Wizards to work
Usage of runWizard
ControlsFX Maven dependency
runWizard helper function