本文整理汇总了Java中javafx.scene.control.ComboBox.setConverter方法的典型用法代码示例。如果您正苦于以下问题:Java ComboBox.setConverter方法的具体用法?Java ComboBox.setConverter怎么用?Java ComboBox.setConverter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.ComboBox
的用法示例。
在下文中一共展示了ComboBox.setConverter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TimeRangeFieldSkin
import javafx.scene.control.ComboBox; //导入方法依赖的package包/类
public TimeRangeFieldSkin(TimeRangeField control) {
super(control);
ComboBox<TimeRangeField.TimeRangeFieldValue> valuesComboBox = new ComboBox<>();
valuesComboBox.setConverter(new TimeRangeFieldValueStringConverter());
valuesComboBox.setItems(control.getValues());
valuesComboBox.valueProperty().bindBidirectional(control.valueProperty());
valuesComboBox.setVisibleRowCount(5);
datePicker = new DatePicker();
datePicker.getEditor().setPrefColumnCount(6);
datePicker.valueProperty().bindBidirectional(control.onDateProperty());
datePicker.managedProperty().bind(datePicker.visibleProperty());
datePicker.setEditable(false);
weekValueFactory = new IntegerSpinnerValueFactory(1, 52);
weekValueFactory.valueProperty().addListener(obs -> control.setOnWeekNumber(weekValueFactory.getValue()));
control.onWeekNumberProperty().addListener(obs -> {
if (control.getOnWeekNumber() != null) {
weekValueFactory.setValue(control.getOnWeekNumber());
}
});
weekNumberSpinner = new Spinner<>();
weekNumberSpinner.setValueFactory(weekValueFactory);
weekNumberSpinner.managedProperty().bind(weekNumberSpinner.visibleProperty());
weekNumberSpinner.setPrefWidth(70);
monthYearValueFactory = new IntegerSpinnerValueFactory(1972, 3000);
monthYearValueFactory.valueProperty().addListener(obs -> control.setMonthYear(monthYearValueFactory.getValue()));
control.monthYearProperty().addListener(obs -> {
if (control.getMonthYear() != null) {
monthYearValueFactory.setValue(control.getMonthYear());
}
});
monthYearSpinner = new Spinner<>();
monthYearSpinner.getEditor().setPrefColumnCount(6);
monthYearSpinner.setValueFactory(monthYearValueFactory);
monthYearSpinner.managedProperty().bind(monthYearSpinner.visibleProperty());
afterUnitsValueFactory = new IntegerSpinnerValueFactory(1, 500);
afterUnitsValueFactory.valueProperty().addListener(obs -> control.setAfterUnits(afterUnitsValueFactory.getValue()));
control.afterUnitsProperty().addListener(obs -> {
if (control.getAfterUnits() != null) {
afterUnitsValueFactory.setValue(control.getAfterUnits());
}
});
afterUnitsSpinner = new Spinner<>();
afterUnitsSpinner.getEditor().setPrefColumnCount(4);
afterUnitsSpinner.setValueFactory(afterUnitsValueFactory);
afterUnitsSpinner.managedProperty().bind(afterUnitsSpinner.visibleProperty());
afterUnitsLabel = new Label();
afterUnitsLabel.managedProperty().bind(afterUnitsLabel.visibleProperty());
InvalidationListener listener = obs -> layout();
control.viewTypeProperty().addListener(listener);
control.valueProperty().addListener(listener);
HBox container = new HBox(5, valuesComboBox, datePicker, weekNumberSpinner, monthYearSpinner, afterUnitsSpinner, afterUnitsLabel);
container.setAlignment(Pos.CENTER_LEFT);
HBox.setHgrow(valuesComboBox, Priority.ALWAYS);
HBox.setHgrow(datePicker, Priority.SOMETIMES);
getChildren().add(container);
layout();
}