public void apply(@Nonnull ComboBox<T> comboBox) { comboBox.setButtonCell(this); comboBox.setCellFactory(param -> new EnumListCell<>()); }
@Nonnull public static <T extends Enum<T>> ComboBox<T> bindEnumComboSpecificEnums(@Nonnull ComboBox<T> combo, @Nonnull ObjectProperty<T> property, @Nonnull Class<T> type, @Nonnull T[] enumConstants) { combo.itemsProperty().set(FXCollections.observableArrayList(enumConstants)); combo.valueProperty().bindBidirectional(property); combo.setButtonCell(new EnumListCell<>()); combo.setCellFactory(param -> new EnumListCell<>()); return combo; }
/** * Setup a combo box * * @param comboBox * the combo box * @param items * the items * @param labelExtractor * function to extract the label * @return the combo box passed in */ public static <T> ComboBox<T> setupCombo(ComboBox<T> comboBox, ObservableList<T> items, @NonNull Function<@Nullable T, @Nullable CharSequence> labelExtractor) { comboBox.setCellFactory(v -> new SimpleListCell<T>(labelExtractor)); comboBox.setButtonCell(new SimpleListCell<>(labelExtractor)); comboBox.setItems(items); return comboBox; }
comboBox.setCellFactory(new Callback<ListView<T>, ListCell<T>>() { @Override public ListCell<T> call(ListView<T> listView) { CheckBoxListCell<T> result = new CheckBoxListCell<>(item -> control.getItemBooleanProperty(item));
comboBox.setCellFactory(cellFactory); final ChangeListener valueChangeListener0 = (arg0, arg1, arg2) -> { final IEnumeratedValueModel selected = comboBox.getSelectionModel().getSelectedItem();
combobox.setCellFactory(cellFactory);
crpComboBox.setCellFactory(CropSelector.<CropData>cdCellFactory(PROP_NAME)); crpComboBox.setButtonCell(CropSelector.<CropData>cdCell(PROP_NAME)); crpComboBox.setDisable(true); vtyComboBox = new ComboBox<>(vtyList); vtyComboBox.setPrefWidth(PREF_WIDTH); vtyComboBox.setCellFactory(CropSelector.<VarietyData>cdCellFactory(PROP_NAME)); vtyComboBox.setButtonCell(CropSelector.<VarietyData>cdCell(PROP_NAME)); vtyComboBox.setDisable(true); clnComboBox = new ComboBox<>(clnList); clnComboBox.setPrefWidth(PREF_WIDTH); clnComboBox.setCellFactory(CropSelector.<ClassificationData>cdCellFactory(PROP_NAME)); clnComboBox.setButtonCell(CropSelector.<ClassificationData>cdCell(PROP_NAME)); clnComboBox.setDisable(true);
comboBox.setCellFactory(cellfactory);
measurePointIdComboBox.setCellFactory(new Callback<ListView<String>, ListCell<String>>() { @Override public ListCell<String> call(ListView<String> param) {
@Override public void run() { MigPane root = new MigPane("wrap 2"); FieldSets.addNameField(root, model); FieldSets.addPeriodFieldSet(root, model); // // adding soil type label and field // Label soilTypeLabel = new Label(Bundle.new_field_view_label_soil_type()); root.add(soilTypeLabel); ComboBox<SoilType> soilTypeComboBox = new ComboBox<>(FXCollections.<SoilType>observableArrayList(SoilType.values())); soilTypeComboBox.setPrefWidth(150.0d); soilTypeComboBox.setCellFactory(descriptionCellFactory(SoilType.class)); root.add(soilTypeComboBox); JFXBinder.bind(Field.PROP_SOIL_TYPE).of(Model.withAt(model, Field.PROP_SOIL_TYPE)).to("value").of(soilTypeComboBox, EnumConverters.stringToEnum(SoilType.class)); JFXBinder.bind("value").of(soilTypeComboBox).to(Field.PROP_SOIL_TYPE).of(Model.withAt(model, Field.PROP_SOIL_TYPE), EnumConverters.enumToString()); Scene scene = new Scene(root, SCENE_WIDTH, SCENE_HEIGHT); StyleManager.Default.applyFormStyle(scene); fxPanel.setScene(scene); } });
ComboBox<SoilType> soilTypeComboBox = new ComboBox<SoilType>(FXCollections.<SoilType>observableArrayList(SoilType.values())); soilTypeComboBox.setPrefWidth(150.0d); soilTypeComboBox.setCellFactory(descriptionCellFactory(SoilType.class)); root.add(soilTypeComboBox); JFXBinder.bind(Field.PROP_SOIL_TYPE).of(Model.withAt(model, Field.PROP_SOIL_TYPE)).to("value").of(soilTypeComboBox, EnumConverters.stringToEnum(SoilType.class));
countryComboBox.setCellFactory(nameCellFactory(Country.class)); root.add(countryComboBox); JFXBinder.bind(HasAddress.PROP_COUNTRY).of(Model.withAt(model, HasAddress.PROP_COUNTRY)).to("value").of(countryComboBox, EnumConverters.stringToEnum(Country.class));