Help with JavaFX form

10

Hello, I imagine that my question is simple but I have not found anything in the forums of life (probably because I do not use the correct terms in the search).

I am creating a form for students in JavaFX generating fxml files with Scene Builder, it is separated in two parts one general data and another for specific. In this case, one part for the student's personal data the other has data about the course of the same. Considering that there are five courses, the fields pertaining to each will be different.

I generated an fxml with the general information fields and left an empty page to embed an fxml for one of the courses.

My goal is to offer a screen to the user with five buttons, one for each course, when he clicks on a complete form is shown.

If anyone knows anything that can help me, please share. Thank you very much.

Adding information

I'm not with my computer so I'll have to use another example, but the images below explain the situation better.

In this project the user can make a food, animal or miscellaneous complaint, they all share common information that can be observed at the top of the form the image below.

Atthebottom,thereisanemptyanchorpanethatwouldliketoloaditwithaspecificformwiththebelow.StackOverflowdidnotallowmetoentermorethantwoimages.

Complaint control class code (general form):

public class QueixaController implements Initializable, IControlledScreen {

private ScreensController controller;
@FXML RadioButton choice;
@FXML DatePicker date;
@FXML ChoiceBox address;
@FXML TextArea descriptions;
@FXML TextArea observations;
@FXML AnchorPane pane;

/**
 * Initializes the controller class.
 */
@Override
public void initialize(URL url, ResourceBundle rb) {    
}    
/**Método usado na transição de telas
@Override
public void setScreenParent(ScreensController controller) {
    this.controller = controller;
}    
}

Code for food complaint control class:

public class QueixaAlimentarController implements Initializable {
@FXML TextField commensal;
@FXML TextField sick;
@FXML TextField deads;
@FXML TextField inHoslpital;

/**
 * Initializes the controller class.
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    // TODO
}     
}

My question is: is there any way to code so that the general data form incorporates a specific data form avoiding to create a complete for each type of complaint, considering that I will have a screen for the user to choose what kind of complaint do?

    
asked by anonymous 24.11.2015 / 03:01

1 answer

3

Well, you need to leave a blank (can be HBox, VBox, Pane etc) empty in the area you are going to add. Then use the following code:

paneVazio.getChildren().setAll(
    FXMLLoader.load(getClass().getResource("arquivo.fxml")) 
);

I did not have time to test, but apparently that's the way to do it.

    
11.05.2016 / 11:48