lundi 17 août 2020

Creating a menuButton with check boxes inside on javafx with scene builder

I have a menu Button and I want to add checkboxes, so that the user will be able to choose multiple symptoms, for some reason when I run the program, the menuButton won't even open, what am I missing?

@FXML
    private MenuButton menuButton;
    
    @FXML
    private CustomMenuItem cough;

    @FXML
    private CustomMenuItem fever;

    .//same for the rest of the symptoms
    .
    
    @FXML
    private CheckBox coughBox;

    private CustomMenuItem fever;

    .////same for the rest of the symptoms
    .

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        coughBox.setUserData(Symptoms.COUGH);
        cough.setUserData(coughBox);
        cough.setHideOnClick(false);
        
        feverBox.setUserData(Symptoms.FEVER);
        fever.setUserData(Symptoms.FEVER);
        fever.setHideOnClick(false);
        
        tirednessBox.setUserData(Symptoms.TIREDNESS);
        tiredness.setUserData(Symptoms.TIREDNESS);
        tiredness.setHideOnClick(false);
        
        difficultyBreathingBox.setUserData(Symptoms.DIFFICULTY_BREATHING);
        difficultyBreathing.setUserData(Symptoms.DIFFICULTY_BREATHING);
        difficultyBreathing.setHideOnClick(false);
        
        backAchesBox.setUserData(Symptoms.BACKHACHES);
        backAches.setUserData(Symptoms.BACKHACHES);
        backAches.setHideOnClick(false);
        
        faintingBox.setUserData(Symptoms.FAINTING);
        fainting.setUserData(Symptoms.FAINTING);
        fainting.setHideOnClick(false);
        
        CustomMenuItem[] tmp = {cough, fever, tiredness, difficultyBreathing, backAches, fainting};
        menuButton.getItems().setAll(FXCollections.observableArrayList(tmp));



Aucun commentaire:

Enregistrer un commentaire