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 cust
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 an Anchor, but this would require LinearFlow being a public type, which is not the case by now (it's an inner class of Wizard in Java 1.8.0_144).
WizardController.java:
public class WizardController {
@FXML
private WizardPane step1Pane;
@FXML
private WizardPane step2Pane;
...
void show() {
Wizard wizard = new Wizard();
wizard.setFlow(new Wizard.LinearFlow(
step1Pane,
step2Pane,
...
));
wizard.resultProperty().addListener((observable, oldValue, newValue) -> {
wizardStage.close();
});
// show wizard and wait for response
Stage wizardStage = new Stage();
wizardStage.setTitle("... wizard");
wizardStage.setScene(wizard.getScene());
wizardStage.show();
}
}
Application class:
public class WizardApp extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void init() throws Exception {
super.init();
...
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("WizardView.fxml"));
wizardController = loader.getController();
}
@FXML
private void showWizard(ActionEvent actionEvent) {
wizardController.show();
}
}