Help with Javafx form

Asked

Viewed 732 times

10

Hello, I imagine my doubt is simple but I haven’t found anything in the forums of life (probably because I don’t 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 to the other has data on the course of the same. Considering that there are five courses, the fields for each will be different.

I generated a fxml with the general information fields and left an empty pane to incorporate a 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 click on a the complete form is shown.

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


Adding information

I don’t have 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 complaint, animal or diverse, all of them share common information that can be observed in the top of the form the image below.

queixa - formulário geral

At the bottom, there is an empty Anchor pane that would like to load it with a specific form with the below. Stack Overflow didn’t allow me to insert more than two images.

queixa alimentar

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 encode for the general data form to incorporate a specific data form avoiding creating a complete for each type of complaint, considering that I will have a screen for the user to choose what type of complaint to make?

  • 1

    Your question is cool, but it’s kind of hard to answer without you posting what you’ve already done or tried to do. You could post what you have already done, even to facilitate the process of writing a reply?

  • I updated the question, I imagine it’s clearer now but if you’re not, let me know that I try to tidy up. Thank you very much.

  • Your question now seems to be fine. I gave my vote to reopen.

1 answer

3


Well, you need to leave an empty pane (can be Hbox, Vbox, Pane etc) in the area you are going to add. Then use the following code :

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

I didn’t have time to test it, but apparently that’s how it’s done.

  • I have been working on this project of these classes for a while, I will search and test. Thanks.

  • The topic is old and I had forgotten that I had asked the question, but in fact this is the best approach I know to solve this problem. Thank you for the reply.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.