-
Notifications
You must be signed in to change notification settings - Fork 290
Description
controlsfx 12.0.0-SNAPSHOT
When a NumericField is created, the initial value of the value filed is set to 0. During the initialization only the text of the TextField is set. Therefore when a user enters 0 for the first time, the NumericField does not identifies it as a change and the listeners are not called.
It may be related to #66.
The user first must enter a non-zero value or click the field to get the focus then leave the filed. When the NumericField loses the focus finally it sets the value to zero.
The problem is in this method. It sets only the text and not the actual value which remains 0.
Editors.createNumericEditor(Item property )
@Override public void setValue(Number value) {
sourceClass = (Class<? extends Number>) value.getClass();
getEditor().setText(value.toString());
}
You can test it. When you enter 0 in the field for the first time, the 0 is not propagated into the bean.
public class PropertySheetApp extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
var bean = new Bean();
bean.setNumber(10);
var items = BeanPropertyUtils.getProperties(bean);
var sheet = new PropertySheet(items);
StackPane pane = new StackPane(sheet);
stage.setScene(new Scene(pane, 300, 250));
stage.show();
}
public static class Bean {
private double number;
public double getNumber() {
return number;
}
public void setNumber(double number) {
System.out.println(number);
this.number = number;
}
}
}