final BigDecimalField disabledField = new BigDecimalField();
disabledField.setDisable(true);
root.addRow(rowIndex++, new Label("disabled field"), disabledField);
root.addRow(rowIndex++, new Label("regular TextField"), new TextField("1.000,1234"));
root.addRow(rowIndex++, new Label("with promptText"), promptText);
CalendarTextField calendarTextField = new CalendarTextField();
root.addRow(rowIndex++, new Label("CalendarTextField"), calendarTextField);
ComboBox<Locale> cmbLocales = new ComboBox<>(FXCollections.observableArrayList(Locale.GERMANY, Locale.UK, Locale.FRANCE));
cmbLocales.setOnAction(event -> {
dateFormatProperty.set(DateFormat.getDateInstance(DateFormat.MEDIUM, cmbLocales.getValue()));
numberFormatProperty.set(NumberFormat.getNumberInstance(cmbLocales.getValue()));
});
root.addRow(rowIndex++, new Label("Locale"), cmbLocales);
root.addRow(rowIndex++, new Label("Field with boundaries (0,100%)"),
BigDecimalFieldBuilder.create()
.number(new BigDecimal("0.1"))
.minValue(BigDecimal.ZERO)
.maxValue(BigDecimal.ONE)
.stepwidth(new BigDecimal("0.01"))
.format(DecimalFormat.getPercentInstance())
.build()
);
promptText.numberProperty().addListener(new ChangeListener<BigDecimal>() {
@Override
public void changed(ObservableValue<? extends BigDecimal> observableValue, BigDecimal o, BigDecimal o1) {
System.out.println(o1);
}
});
Button button = new Button("Reset fields");
button.setOnAction((ActionEvent event) -> {
defaultSpinner.setNumber(new BigDecimal(Math.random() * 1000));
decimalFormat.setNumber(new BigDecimal(Math.random() * 1000));
percent.setNumber(new BigDecimal(Math.random()));
localizedCurrency.setNumber(new BigDecimal(Math.random() * 1000));
disabledField.setNumber(new BigDecimal(Math.random() * 1000));
promptText.setNumber(null);
calendarTextField.setCalendar(Calendar.getInstance());
decimalFormat.requestFocus();
});
root.addRow(rowIndex++, new Label(), button);
BigDecimalLabel bigDecimalLabel = new BigDecimalLabel();
bigDecimalLabel.numberProperty().bind(defaultSpinner.numberProperty());
bigDecimalLabel.formatProperty().bind(numberFormatProperty);
root.addRow(rowIndex++, new Label("BigDecimalLabel"), bigDecimalLabel);
CalendarLabel calendarLabel = new CalendarLabel();
calendarLabel.valueProperty().bind(calendarTextField.calendarProperty());
calendarLabel.formatProperty().bind(dateFormatProperty);
root.addRow(rowIndex++, new Label("CalendarLabel"), calendarLabel);
// defaultSpinner.requestFocus();
// calendarTextField.requestFocus();
Platform.runLater(new Runnable() {