vendredi 4 décembre 2020

JavaFX CheckBox returning null before being chosen

I am working on a javaFX project and the checkboxes I'm working with are returning null when initially run and my button that checks the value of the previously mentioned checkboxes. However, when I run the button without selecting either of the checkboxes, they return null. How do I fix this? Relevant code attached

           boolean withWithout = false;
           if(nutsButton.isSelected() == true) {
                   withWithout = true;}//end if 
               else if(nutsButton.isSelected() == false) {
                   withWithout = false;}//end else if
               everythingElse.setNuts(withWithout);
            }//end method
           
            public void cherriesButtonListener() {
                boolean withWithout = true;
                if(cherriesButton.isSelected())
                    withWithout = true;
                else if(cherriesButton.isSelected() == false)
                    withWithout = false;
                everythingElse.setCherries(withWithout);
            }'''
Thank you :)



Aucun commentaire:

Enregistrer un commentaire