本文整理匯總了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());
}