本文整理汇总了Java中javafx.scene.control.Spinner.getValueFactory方法的典型用法代码示例。如果您正苦于以下问题:Java Spinner.getValueFactory方法的具体用法?Java Spinner.getValueFactory怎么用?Java Spinner.getValueFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.Spinner
的用法示例。
在下文中一共展示了Spinner.getValueFactory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: commitEditorText
import javafx.scene.control.Spinner; //导入方法依赖的package包/类
private void commitEditorText(Spinner<T> spinner) {
if (!spinner.isEditable()) return;
try {
String text = spinner.getEditor().getText();
SpinnerValueFactory<T> valueFactory = spinner.getValueFactory();
if (valueFactory != null) {
StringConverter<T> converter = valueFactory.getConverter();
if (converter != null) {
T value = converter.fromString(text);
if (value == null)
return;
valueFactory.setValue(value);
}
}
} catch (NumberFormatException e) {
// Ignore text input.
return;
}
}
示例2: commitEditorText
import javafx.scene.control.Spinner; //导入方法依赖的package包/类
private <T> void commitEditorText(Spinner<T> spinner) {
if (!spinner.isEditable()) {
return;
}
String text = spinner.getEditor().getText();
SpinnerValueFactory<T> valueFactory = spinner.getValueFactory();
if (valueFactory != null) {
StringConverter<T> converter = valueFactory.getConverter();
if (converter != null) {
T value = converter.fromString(text);
valueFactory.setValue(value);
}
}
}
示例3: makeListeningForManualValueUpdates
import javafx.scene.control.Spinner; //导入方法依赖的package包/类
/**
* Links a spinners value property to its factory's value property which has the effect, that it also is notified on manual updates
* (as opposed to pressing the spinner buttons).
*/
private <T> void makeListeningForManualValueUpdates(Spinner<T> spinner) {
SpinnerValueFactory<T> valueFactory = spinner.getValueFactory();
TextFormatter<T> formatter = new TextFormatter<>(valueFactory.getConverter(), valueFactory.getValue());
spinner.getEditor().setTextFormatter(formatter);
valueFactory.valueProperty().bindBidirectional(formatter.valueProperty());
}