How to clean ChoiceBox without losing items?

0

I made ChoiceBox , but a problem occurs; when I leave the stage and then return, the ChoiceBox continues with the previously chosen item. I want it to come out and then return, it goes back to the initial state, that is, with no chosen item.

How to do this? Look at part of the code:

cb.getSelectionModel().selectedIndexProperty().addListener((ObservableValue<? extends Number> obs, Number old , Number newValue)->{

        switch(newValue.intValue()){

            case 0:

                validarSemChoiceBox = true;
                nivelDaTarefa = fonemas;
                new TictactoeViewController().limparJogo();

                break;

            case 1:

                validarSemChoiceBox = true;
                nivelDaTarefa = silabas;
                new TictactoeViewController().limparJogo();

                break;


            case 2:

                validarSemChoiceBox = true;
                nivelDaTarefa = palavras;
                new TictactoeViewController().limparJogo();

                break;

        }
    });
    
asked by anonymous 15.05.2015 / 21:19

1 answer

0

Try calling this method to clear selection:

choiceBox.getSelectionModel().clearSelection();
    
23.08.2015 / 08:54