ADDITIONAL SYSTEM INFORMATION :
OS: Win11
JavaVersion:17
javaFX:17.0.7
A DESCRIPTION OF THE PROBLEM :
The validation of Spinner textFiled input is set, resulting in an unvalidated value
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Enter a negative value in the text box
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
newValue = 0.0
ACTUAL -
newValue = -1.0
newValue = 0.0
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Spinner;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class SpinnerTest extends Application {
private final Spinner<Double> spinner = new Spinner<>(0.0, 10.0, 0.0);
private final HBox root = new HBox(spinner);
@Override
public void init() throws Exception {
root.setAlignment(Pos.CENTER);
spinner.setEditable(true);
spinner.valueProperty().addListener((observable, oldValue, newValue) -> {
// There should be no negative values
System.out.println("newValue = " + newValue);
});
}
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle(getClass().getSimpleName());
Scene scene = new Scene(root, 800, 600);
primaryStage.setScene(scene);
primaryStage.show();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The value of the Spinner is bound to the value of the valueFactory, and the execution of editor commitValue() causes problems in the verification order
OS: Win11
JavaVersion:17
javaFX:17.0.7
A DESCRIPTION OF THE PROBLEM :
The validation of Spinner textFiled input is set, resulting in an unvalidated value
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Enter a negative value in the text box
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
newValue = 0.0
ACTUAL -
newValue = -1.0
newValue = 0.0
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Spinner;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class SpinnerTest extends Application {
private final Spinner<Double> spinner = new Spinner<>(0.0, 10.0, 0.0);
private final HBox root = new HBox(spinner);
@Override
public void init() throws Exception {
root.setAlignment(Pos.CENTER);
spinner.setEditable(true);
spinner.valueProperty().addListener((observable, oldValue, newValue) -> {
// There should be no negative values
System.out.println("newValue = " + newValue);
});
}
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle(getClass().getSimpleName());
Scene scene = new Scene(root, 800, 600);
primaryStage.setScene(scene);
primaryStage.show();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The value of the Spinner is bound to the value of the valueFactory, and the execution of editor commitValue() causes problems in the verification order