Skip to content

Commit 0ddd640

Browse files
committed
优化Spinner控件修改监听。
1 parent 1c89fd7 commit 0ddd640

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/main/java/com/xwintop/xJavaFxTool/utils/JavaFxViewUtil.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ public static void setSpinnerValueFactory(Spinner<Integer> spinner, int min, int
166166
IntegerSpinnerValueFactory secondStart_0svf = new SpinnerValueFactory.IntegerSpinnerValueFactory(min, max,
167167
initialValue, amountToStepBy);
168168
spinner.setValueFactory(secondStart_0svf);
169+
spinner.getEditor().textProperty().addListener((observable, oldValue, newValue) -> {
170+
spinner.getValueFactory().setValue(Integer.parseInt(newValue));
171+
});
169172
}
170173

171174
/**

0 commit comments

Comments
 (0)