Example usage for javafx.beans.property StringProperty bindBidirectional

List of usage examples for javafx.beans.property StringProperty bindBidirectional

Introduction

In this page you can find the example usage for javafx.beans.property StringProperty bindBidirectional.

Prototype

@Override
public void bindBidirectional(Property<String> other) 

Source Link

Usage

From source file:Main.java

License:asdf

public static void main(String[] args) {
    StringProperty prop1 = new SimpleStringProperty("");
    StringProperty prop2 = new SimpleStringProperty("");

    prop2.bindBidirectional(prop1);

    System.out.println("prop1.isBound() = " + prop1.isBound());
    System.out.println("prop2.isBound() = " + prop2.isBound());

    prop1.set("asdf");
    System.out.println(prop2.get());

    prop2.set(prop2.get());/*  w  w w. j a  va  2  s  .  co m*/
    System.out.println(prop1.get());
}

From source file:Main.java

public static void main(String[] args) {
    User contact = new User("Jame", "Bind");
    StringProperty fname = new SimpleStringProperty();
    fname.bindBidirectional(contact.firstNameProperty());

    contact.firstNameProperty().set("new value");
    fname.set("New First Name");

    System.out.println("firstNameProperty = " + contact.firstNameProperty().get());
    System.out.println("fname = " + fname.get());

}

From source file:Main.java

public static void main(String[] args) {
    Student contact = new Student("FirstName", "LastName");
    StringProperty fname = new SimpleStringProperty();
    fname.bindBidirectional(contact.firstNameProperty());
    StringProperty lname = new SimpleStringProperty();
    lname.bindBidirectional(contact.lastNameProperty());

    System.out.println(fname.getValue() + " " + lname.getValue());
    System.out.println(contact.getFirstName() + " " + contact.getLastName());

    fname.setValue("new FirstName");
    lname.setValue("new LastName");

    System.out.println(fname.getValue() + " " + lname.getValue());
    System.out.println(contact.getFirstName() + " " + contact.getLastName());
}

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:edu.kit.trufflehog.model.configdata.SettingsDataModelTest.java

/**
 * <p>/*w  w w  .  jav a2s .c  om*/
 *     Checks if the retrieved values match the expected values and changes some of the values, and then checks if
 *     the file was updated by changing the value back to the original value.
 * </p>
 *
 * @param classType The class of the value
 * @param key The key of the value
 * @param oldValue The starting value to check against
 * @param newValue The new value to check against after is has been set
 * @throws Exception Passes any errors that occurred during the test on
 */
private void testGetEntrySuccess(Class classType, String key, String oldValue, String newValue)
        throws Exception {
    settingsDataModel = new SettingsDataModel(fileSystem);
    StringProperty property1 = settingsDataModel.get(classType, key);
    assertEquals(true, property1.getValue().equals(oldValue));

    StringProperty property2 = new SimpleStringProperty(property1.getValue());
    property1.bindBidirectional(property2);

    property2.setValue(newValue);

    Thread.sleep(1000); // sleep because the saving to file happens in another thread

    settingsDataModel = new SettingsDataModel(fileSystem);
    property1 = settingsDataModel.get(classType, key);
    assertEquals(true, property1.getValue().equals(newValue));

    property1.setValue(oldValue);

    Thread.sleep(1000); // sleep because the saving to file happens in another thread

    settingsDataModel = new SettingsDataModel(fileSystem);
    property1 = settingsDataModel.get(classType, key);
    assertEquals(true, property1.getValue().equals(oldValue));
}