1

I want to have a form that has some basic header information (name, date, etc.). Under this header information the user should be able to choose from a ChoiceBox. Below the ChoiceBox there is a ScrollPane. The content of the ScrollPane should be dependent on what was chosen in the ChoiceBox.

What would be the JavaFX way to do this? What should the content of the ScrollPane be? A scene? A Layout? Can I simulate this in the Scenebuilder as well or can I only do one scene at a time? How much of this will be in FXML and how much in the controller class?

I think I could figure out how to do this on my own, but I don't want to do it in some ugly way, but in the way JavaFX would want me to do it.

Thanks

2 Answers 2

1

This is quite easy, you could change the contents of the scroll box depending on the value of the choice box. And I don't really know if you can do this strait in JavaFX but just open the project with your IDE and do it.

if(choiceBox.value == 1) {
     //Draw stuff if first value is selected.    
}else if(choiceBox.value == 2) {
    //Draw stuff if second value is selected.
}else if(choiceBox.value == 3) {
    //Draw stuff if third value is selected.
}

I have barely worked with JavaFX but from what I know you aren't able to do this strait out of their program.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, but this is not really specific.
1

There is a brief description of JavaFX best practices here: http://docs.oracle.com/javafx/2/best_practices/jfxpub-best_practices.htm. It discusses the Henley Sales demo app, which you can download here: http://www.oracle.com/technetwork/java/javase/downloads/index.html. Click on Demos and Samples to get to the actual download page. Inside there is project called DataApp which is the implementation of the Henley Sales Demo project. It takes a fair amount of work to set it up (and I haven't done so yet) but even without running it, you can examine the code to see some best practices following the Model-View-Controller paradigm. It handles common functionality in the outer FXML and individual tabs in nested FXML files and shows you how to attach Controllers to each.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.