package test; import java.util.Arrays; import javafx.application.Application; import javafx.collections.FXCollections; import javafx.collections.ObservableList; 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.HBox; import javafx.stage.Stage; public class ChoiceBoxTest extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) { System.out.println(System.getProperties().get("javafx.runtime.version")); final ChoiceBox cb = new ChoiceBox(); Button b = new Button(); b.setText("Populate Menu"); b.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { ObservableList choices = FXCollections.observableList(Arrays.asList("One", "Two", "Three")); cb.setItems(choices); } }); HBox root = new HBox(); root.setSpacing(10); root.getChildren().addAll(b, cb); stage.setScene(new Scene(root, 200, 100)); stage.show(); } }