This discussion is archived
1 Reply Latest reply: Jan 3, 2013 9:13 AM by James_D RSS

ChoiceBox not "refreshing the selection"

966626 Newbie
Currently Being Moderated
I have the following code:
The event is fired up and the values received by the event handler are correct, the function does everything right but the choicebox is still showing to the user the same item selected than before the code was issued.
Any help will be appreciated.
  • 1. Re: ChoiceBox not "refreshing the selection"
    James_D Guru
    Currently Being Moderated
    This works fine for me:
    import javafx.application.Application;
    import javafx.collections.FXCollections;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.ChoiceBox;
    import javafx.scene.layout.BorderPane;
    import javafx.stage.Stage;
    public class ChoiceBoxSelectionTest extends Application {
      public void start(Stage primaryStage) {
        final BorderPane root = new BorderPane();
        final ChoiceBox<String> choiceBox = new ChoiceBox<>(
            FXCollections.observableArrayList("Apples", "Oranges", "Pears",
        final Button button = new Button("Select First");
        button.setOnAction(new EventHandler<ActionEvent>() {
          public void handle(ActionEvent event) {
        Scene scene = new Scene(root, 200, 400);
      public static void main(String[] args) {
    Can you post a short executable example which demonstrates the problem?


  • Correct Answers - 10 points
  • Helpful Answers - 5 points