How to clean Choicebox without losing the items?

Asked

Viewed 48 times

0

I made a ChoiceBox, but a problem occurs; when I leave the stage and then return, the ChoiceBox continues with the previously chosen item. I want that when leaving and then returning, it returns to the initial state, that is, without chosen item.

How to do that? Look at a 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;

        }
    });

1 answer

0

Try calling this method to clear selection:

choiceBox.getSelectionModel().clearSelection();

Browser other questions tagged

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