Example usage for javafx.util.converter NumberStringConverter NumberStringConverter

List of usage examples for javafx.util.converter NumberStringConverter NumberStringConverter

Introduction

In this page you can find the example usage for javafx.util.converter NumberStringConverter NumberStringConverter.

Prototype

public NumberStringConverter() 

Source Link

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    ChoiceBox<String> choiceBox = new ChoiceBox<String>(cursors);

    StringConverter sc = new NumberStringConverter();

    choiceBox.setConverter(sc);/*from   w  w  w.  j  av a2s.  c  o  m*/

    VBox box = new VBox();
    box.getChildren().add(choiceBox);
    final Scene scene = new Scene(box, 300, 250);
    scene.setFill(null);
    stage.setScene(scene);
    stage.show();
}

From source file:de.ks.standbein.sample.fieldbinding.activity.FieldBindingController.java

private void bindModelPropertiesToControls() {
    //bind the name to the name field
    //binding is bidirectional, so when we save the model the new values are applied to the fields
    StringProperty modleName = store.getBinding().getStringProperty(FieldBindingExampleModel.class,
            FieldBindingExampleModel::getName);
    modleName.bindBidirectional(stringField.textProperty());

    //bind the value to the int field using a numberconverter to convert from and to the integer
    IntegerProperty modelValue = store.getBinding().getIntegerProperty(FieldBindingExampleModel.class,
            FieldBindingExampleModel::getValue);
    intField.textProperty().bindBidirectional(modelValue, new NumberStringConverter());

    //object bindings are also valid
    ObjectProperty<LocalDate> modelDate = store.getBinding().getObjectProperty(FieldBindingExampleModel.class,
            FieldBindingExampleModel::getDate);
    dateField.valueProperty().bindBidirectional(modelDate);
}

From source file:org.kordamp.javatrove.example04.view.AppView.java

public Scene createScene() {
    String basename = getClass().getPackage().getName().replace('.', '/') + "/app";
    URL fxml = getClass().getClassLoader().getResource(basename + ".fxml");
    FXMLLoader fxmlLoader = new FXMLLoader(fxml);
    fxmlLoader.setControllerFactory(param -> AppView.this);
    Parent root = null;//  w w  w.j  a  v a 2 s.com
    try {
        root = (Parent) fxmlLoader.load();
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }

    organization.textProperty().addListener((observable, oldValue, newValue) -> {
        model.setState(isBlank(newValue) ? DISABLED : READY);
    });

    model.stateProperty().addListener((observable, oldValue, newValue) -> Platform.runLater(() -> {
        switch (newValue) {
        case DISABLED:
            enabled.setValue(false);
            running.setValue(false);
            break;
        case READY:
            enabled.setValue(true);
            running.setValue(false);
            break;
        case RUNNING:
            enabled.setValue(false);
            running.setValue(true);
            break;
        }
    }));

    ObservableList<Repository> items = createJavaFXThreadProxyList(model.getRepositories().sorted());

    repositories.setItems(items);
    EventStreams.sizeOf(items).subscribe(v -> total.setText(String.valueOf(v)));
    organization.textProperty().bindBidirectional(model.organizationProperty());
    bindBidirectional(limit.textProperty(), model.limitProperty(), new NumberStringConverter());
    loadButton.disableProperty().bind(Bindings.not(enabled));
    cancelButton.disableProperty().bind(Bindings.not(running));
    progress.visibleProperty().bind(running);

    Scene scene = new Scene(root);
    scene.getStylesheets().addAll(basename + ".css", "bootstrapfx.css");
    return scene;
}

From source file:com.hengyi.japp.print.client.controller.MdController.java

public void initMd(Md _md) {
    md = _md;/*from   w  w w . j  a  v a 2s  .c o m*/
    chargLabel.textProperty().bind(md.chargProperty());
    hsdatField.valueProperty().bindBidirectional(md.hsdatProperty());

    sapYmmbanciField.valueProperty().bindBidirectional(md.sapYmmbanciProperty());
    sapYmmbanciField.itemsProperty().bind(md.getSapT001().sapYmmbancisProperty());

    sapT001wField.valueProperty().bindBidirectional(md.sapT001wProperty());
    sapT001wField.itemsProperty().bind(md.getSapT001().sapT001wsProperty());
    //        sapT001wField.valueProperty().addListener((ov, oldV, newV) -> sapT001wLabel.textProperty().bind(newV.name1Property()));
    //        sapT001wField.setCellFactory(SAPT001WCELLFACTORY);

    sapT001lField.valueProperty().bindBidirectional(md.sapT001lProperty());
    sapT001lField.itemsProperty().bind(md.getSapT001w().sapT001lsProperty());
    //        sapT001lField.valueProperty().addListener((ov, oldV, newV) -> sapT001lLabel.textProperty().bind(newV.lgobeProperty()));
    //        sapT001lField.setCellFactory(SAPT001LCELLFACTORY);

    sapZpackageField.valueProperty().bindBidirectional(md.sapZpackageProperty());
    sapZpackageField.itemsProperty().bind(md.getSapT001().sapZpackagesProperty());

    sapYmmzhixField.valueProperty().addListener(
            (ov, oldV, newV) -> sapYmmzhixLabel.setText(newV == null ? null : newV.getYzxwght() + " KG"));
    sapYmmzhixField.valueProperty().bindBidirectional(md.sapYmmzhixProperty());
    sapYmmzhixField.itemsProperty().bind(md.getSapT001().sapYmmzhixsProperty());
    //        sapYmmzhixField.setCellFactory(SAPYMMZHIXCELLFACTORY);

    sapYmmtonggField.valueProperty().addListener(
            (ov, oldV, newV) -> sapYmmtonggLabel.setText(newV == null ? null : newV.getZtgwght() + " KG"));
    sapYmmtonggField.valueProperty().bindBidirectional(md.sapYmmtonggProperty());
    sapYmmtonggField.itemsProperty().bind(md.getSapT001().sapYmmtonggsProperty());
    //        sapYmmtonggField.setCellFactory(SAPYMMTONGGCELLFACTORY);
    zrolmgeField.textProperty().bindBidirectional(md.zrolmgeProperty(), new NumberStringConverter());

    sapYmmmachField.valueProperty().bindBidirectional(md.sapYmmmachProperty());
    sapYmmmachField.itemsProperty().bind(md.getSapT001().sapYmmmachsProperty());
    //        sapYmmmachField.valueProperty().addListener((ov, oldV, newV) -> sapYmmmachLabel.setText(newV == null ? null : newV.getZplant()));
    //        sapYmmmachField.setCellFactory(SAPYMMMACHCELLFACTORY);

    //        sapYmmcheField.valueProperty().bindBidirectional(md.sapYmmcheProperty());
    //        sapYmmcheField.itemsProperty().bind(md.getSapT001().sapymm());
    //        sapYmmcheField.setCellFactory(SAPYMMCHECELLFACTORY);
    //        sapYmmcheField.valueProperty().addListener((ov, oldV, newV) -> sapYmmcheLabel.setText(newV == null ? null : newV.getZchwght() + " KG"));

    zcanmgeField.textProperty().bindBidirectional(md.zcanmgeProperty(), new NumberStringConverter());
    zdzflgField.selectedProperty().bindBidirectional(md.zdzflgProperty());
    zcnwghtField.textProperty().bindBidirectional(md.zcnwghtProperty(), new BigDecimalStringConverter());

    xdTable.itemsProperty().bindBidirectional(md.xdsProperty());
    sumZsgwghtLabel.textProperty().bindBidirectional(md.zsgwghtProperty(), new BigDecimalStringConverter());
    sumZsnwghtLabel.textProperty().bindBidirectional(md.zsnwghtProperty(), new BigDecimalStringConverter());

    if (StringUtils.isNotBlank(md.getCharg())) {
        sapMaraListView.setVisible(false);
        Platform.runLater(() -> matnrField.requestFocus());
    }
}

From source file:com.github.drbookings.ui.controller.BookingDetailsController.java

private void addRowNetEarnings(final Pane content, final BookingBean be) {
    final HBox box = new HBox();
    box.setSpacing(boxSpacing);/*from w  w  w.ja v a  2 s .com*/
    box.setPadding(boxPadding);
    box.setAlignment(Pos.CENTER_LEFT);
    box.setFillHeight(true);
    final TextField grossEarningsExpression = new TextField(be.getGrossEarningsExpression());
    grossEarningsExpression.setPrefWidth(prefTextInputFieldWidth * 1.5);
    booking2GrossEarnings.put(be, grossEarningsExpression);
    final Text grossEarnings = new Text(decimalFormat.format(be.getGrossEarnings()));
    final TextFlow tf = new TextFlow(new Text("Gross Earnings: "), grossEarningsExpression, new Text(" = "),
            grossEarnings, new Text(""));
    box.getChildren().addAll(tf);
    if (be.getGrossEarnings() <= 0) {
        box.getStyleClass().addAll("warning", "warning-bg");
    }

    final HBox box2 = new HBox();
    box2.setSpacing(boxSpacing);
    box2.setPadding(boxPadding);
    box2.setAlignment(Pos.CENTER_LEFT);
    box2.setFillHeight(true);

    Text text = new Text("Amount received: ");
    TextField textField = new TextField();
    textField.setText(new NumberStringConverter().toString(be.getPaymentSoFar()));
    textField.setEditable(false);
    be.paymentSoFarProperty().addListener((c, o, n) -> {
        textField.setText(new NumberStringConverter().toString(n));
    });
    box2.getChildren().addAll(text, textField);
    content.getChildren().addAll(box, box2);

}