How to use Wizards in 8.20.7

785 views
Skip to first unread message

miniHessel

unread,
Oct 6, 2014, 3:57:34 AM10/6/14
to control...@googlegroups.com
 am trying to develop a wizard using the new ControlsFX 8.20.7 release. I have taken a look at the following example: BitBucket ControlsFX, and especially the method 
showLinearWizard() 

I simply can't understand how to use this API, can anyone help me get going or link to some examples?

This is my code right now, full of errors:


public class WizardTest extends Application {

private final ComboBox<StageStyle> styleCombobox = new ComboBox<>();
private final ComboBox<Modality> modalityCombobox = new ComboBox<>();
private final CheckBox cbUseBlocking = new CheckBox();
private final CheckBox cbCloseDialogAutomatically = new CheckBox();
private final CheckBox cbShowMasthead = new CheckBox();
private final CheckBox cbSetOwner = new CheckBox();
private final CheckBox cbCustomGraphic = new CheckBox();

private Stage stage;

@Override
public void start(Stage primaryStage) {
    Button btn = new Button();
    btn.setText("Say 'Hello World'");
    btn.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            showLinearWizard();
        }
    });

    StackPane root = new StackPane();
    root.getChildren().add(btn);

    Scene scene = new Scene(root, 300, 250);

    primaryStage.setTitle("Hello World!");
    primaryStage.setScene(scene);
    primaryStage.show();

}

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    launch(args);

}

private void showLinearWizard() {
    // define pages to show

    Wizard wizard = new Wizard();
    wizard.setTitle("Linear Wizard");

    // --- page 1
    int row = 0;

    GridPane page1Grid = new GridPane();
    page1Grid.setVgap(10);
    page1Grid.setHgap(10);

    page1Grid.add(new Label("First Name:"), 0, row);
    TextField txFirstName = createTextField("firstName");
    wizard.getValidationSupport().registerValidator(txFirstName, Validator.createEmptyValidator("First Name is mandatory"));  
    page1Grid.add(txFirstName, 1, row++);

    page1Grid.add(new Label("Last Name:"), 0, row);
    TextField txLastName = createTextField("lastName");
   wizard.getValidationSupport().registerValidator(txLastName, Validator.createEmptyValidator("Last Name is mandatory"));
    page1Grid.add(txLastName, 1, row);

    WizardPane page1 = new WizardPane();
    page1.setHeaderText("Please Enter Your Details");
    page1.setContent(page1Grid);

    // --- page 2
    final WizardPane page2 = new WizardPane() {
        @Override
        public void onEnteringPage(Wizard wizard) {
            String firstName = (String) wizard.getSettings().get("firstName");
            String lastName = (String) wizard.getSettings().get("lastName");

            setContentText("Welcome, " + firstName + " " + lastName + "! Let's add some newlines!\n\n\n\n\n\n\nHello World!");
        }
    };
    page2.setHeaderText("Thanks For Your Details!");

    // --- page 3
    WizardPane page3 = new WizardPane();
    page3.setHeaderText("Goodbye!");
    page3.setContentText("Page 3, with extra 'help' button!");

    ButtonType helpDialogButton = new ButtonType("Help", ButtonData.HELP_2);
    page3.getButtonTypes().add(helpDialogButton);
    Button helpButton = (Button) page3.lookupButton(helpDialogButton);
    helpButton.addEventFilter(ActionEvent.ACTION, actionEvent -> {
        actionEvent.consume(); // stop hello.dialog from closing
        System.out.println("Help clicked!");
    });

    // create wizard
    wizard.setFlow(new LinearFlow(page1, page2, page3));

    System.out.println("page1: " + page1);
    System.out.println("page2: " + page2);
    System.out.println("page3: " + page3);

    // show wizard and wait for response
    wizard.showAndWait().ifPresent(result -> {
        if (result == ButtonType.FINISH) {
            System.out.println("Wizard finished, settings: " + wizard.getSettings());
        }
    });
}

private TextField createTextField(String id) {
    TextField textField = new TextField();
    textField.setId(id);
    GridPane.setHgrow(textField, Priority.ALWAYS);
    return textField;
}

}

Jonathan Giles

unread,
Oct 6, 2014, 4:10:11 AM10/6/14
to control...@googlegroups.com
miniHessel,

I took the code you pasted below, imported all the missing imports, and it run fine. It seems to me that you may be struggling to understand Java basics such as import statements. Please take the time to understand the basics of Java before asking the ControlsFX community to help you with your problems - we need to keep this mailing list focused on ControlsFX-specific discussion.

Thanks,
-- Jonathan

--
You received this message because you are subscribed to the Google Groups "ControlsFX" group.
To unsubscribe from this group and stop receiving emails from it, send an email to controlsfx-de...@googlegroups.com.
To post to this group, send email to control...@googlegroups.com.
Visit this group at http://groups.google.com/group/controlsfx-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/controlsfx-dev/acdcaa7e-b4b2-4ab2-b97e-4e8c32d124f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

miniHessel

unread,
Oct 6, 2014, 4:18:52 AM10/6/14
to control...@googlegroups.com, Jona...@jonathangiles.net
I do understand Java basics, and I have imported everything NetBeans detects on "organze imports", but still I get a lot of errors.

The imports I currently have:


import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.StackPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import org.controlsfx.control.ButtonBar.ButtonType;
import org.controlsfx.dialog.Wizard;
import org.controlsfx.dialog.Wizard.LinearFlow;
import org.controlsfx.dialog.Wizard.WizardPane;
...

Jonathan Giles

unread,
Oct 6, 2014, 4:20:40 AM10/6/14
to miniHessel, control...@googlegroups.com
If you had those imports you should have pasted them in your code example (and also you need to be clearer about what "full of errors" means). The imports that Eclipse added are different:


import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonBar.ButtonData;
import javafx.scene.control.ButtonType;

import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.StackPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

import org.controlsfx.dialog.Wizard;
import org.controlsfx.dialog.Wizard.LinearFlow;
import org.controlsfx.dialog.Wizard.WizardPane;
import org.controlsfx.validation.Validator;


-- Jonathan

On 6/10/2014 9:15 p.m., miniHessel wrote:
I have the following imports, so which am I missing?


import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.StackPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import org.controlsfx.control.ButtonBar.ButtonType;
import org.controlsfx.dialog.Wizard;
import org.controlsfx.dialog.Wizard.LinearFlow;
import org.controlsfx.dialog.Wizard.WizardPane;



kl. 10:10:11 UTC+2 mandag 6. oktober 2014 skrev Jonathan Giles følgende:
...

miniHessel

unread,
Oct 6, 2014, 4:25:34 AM10/6/14
to control...@googlegroups.com, arn...@gmail.com, Jona...@jonathangiles.net
It's actually import errors, like:

cannot find symbol method setHeaderText()

and 

The type of showAndWait()  is erroneuos



And if I use your imports I get the following errors:

Package  javafx.scene.control.ButtonBar.ButtonData does not exist
Cannot find symbol class ButtonType
public class WizardTest extends Application {


    GridPane page1Grid = </
...

Jonathan Giles

unread,
Oct 6, 2014, 4:29:17 AM10/6/14
to control...@googlegroups.com
It sounds to me like you're using either the wrong version of JavaFX (you need to be using 8u20), or you aren't importing openjfx-dialogs. I'd start by saying you probably don't have openjfx-dialogs on your classpath.

-- Jonathan

--
You received this message because you are subscribed to the Google Groups "ControlsFX" group.
To unsubscribe from this group and stop receiving emails from it, send an email to controlsfx-de...@googlegroups.com.
To post to this group, send email to control...@googlegroups.com.
Visit this group at http://groups.google.com/group/controlsfx-dev.

miniHessel

unread,
Oct 6, 2014, 4:37:16 AM10/6/14
to control...@googlegroups.com, Jona...@jonathangiles.net
I downloaded the ControlsFX 8.20.7 at the FXExperience webpage here:

For ControlsFX 8.20.7, there is just one download:


So it isn't enough to add the ControlsFX jar?

...

Jonathan Giles

unread,
Oct 6, 2014, 4:39:49 AM10/6/14
to miniHessel, control...@googlegroups.com
No - as mentioned in the release notes there is an external dependency on openjfx-dialogs that is not included in the download zip file. You can download it from http://releases.controlsfx.org.
-- Jonathan

miniHessel

unread,
Oct 6, 2014, 4:54:15 AM10/6/14
to control...@googlegroups.com, arn...@gmail.com, Jona...@jonathangiles.net
Thank you Jonathan. 

So I just download the Controlsfx-8.20.7.jar from that link, and I am good to go? 
public class WizardTest e
xtends Application {

    root.getChildren<sp
...

Jonathan Giles

unread,
Oct 6, 2014, 4:56:03 AM10/6/14
to miniHessel, control...@googlegroups.com
No - you already have that file. You need to download openjfx-dialogs.
-- Jonathan

miniHessel

unread,
Oct 6, 2014, 5:01:23 AM10/6/14
to control...@googlegroups.com, arn...@gmail.com, Jona...@jonathangiles.net
Thank you Jonathan. It works great. Sorry that I didn't catch the Dialogs file. 
Reply all
Reply to author
Forward
0 new messages