public ComboBoxSample() { HBox hbox = HBoxBuilder.create().alignment(Pos.CENTER).spacing(15).build(); //Non-editable combobox. Created with a builder ComboBox uneditableComboBox = ComboBoxBuilder.create() .id("uneditable-combobox") .promptText("Make a choice...") .items(FXCollections.observableArrayList(strings.subList(0, 8))).build(); //Editable combobox. Use the default item display length ComboBox<String> editableComboBox = new ComboBox<String>(); editableComboBox.setId("second-editable"); editableComboBox.setPromptText("Edit or Choose..."); editableComboBox.setItems(strings); editableComboBox.setEditable(true); hbox.getChildren().addAll(uneditableComboBox, editableComboBox); getChildren().add(hbox); }
@SuppressWarnings("restriction") @Override public void start(Stage stage) { List<String> list = new ArrayList<>(Arrays.asList(strs)); ComboBox<?> combo = ComboBoxBuilder.create(). prefWidth(150). //items(list). items(FXCollections.observableArrayList(list)).//"aa", "bb", "bb")); //promptText(resourceBundle.getString("search.prompt.owner")). promptText("Choice"). build(); //combo.setItems((ObservableList<?>) FXCollections.observableArrayList(list));//"aa", "bb", "bb")); SelectableTitledPane ownerParams = new SelectableTitledPane( //resourceBundle.getString("search.checkbox.owner"), "checkbox", combo); StackPane pane = new StackPane(); pane.setBackground(null); pane.setPadding(new Insets(10, 10, 10, 10)); pane.getChildren().addAll( ownerParams); Scene scene = new Scene(pane); stage.setScene(scene); stage.show(); }