Answer the question
In order to leave comments, you need to log in
How to make data binding in JavaFX 2?
I rarely work with the client-side, maybe that's why such a problem arose.
So, what data binding possibilities I found in java fx:
1. Through ChangeListener:
@FXML
private TextField firstNameField;
private Person person;
public void initialize(final URL arg0, final ResourceBundle arg1) {
firstNameField.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(final ObservableValue<? extends String> paramObservableValue,
final String paramT1, final String paramT2) {
person.setFirstName(paramT2);
}
});
}
@FXML
private TextField firstNameField;
private final StringProperty firstName = new SimpleStringProperty(this, "firstName");
public void initialize(final URL arg0, final ResourceBundle arg1) {
Bindings.bindBidirectional(firstNameField.textProperty(), firstName);
}
public class Person {
private StringProperty firstName = new SimpleStringProperty(this, "firstName", "");
public final String getFirstName() { return firstName.get(); }
public final void setFirstName(String value) { firstName.set(value); }
public final StringProperty firstNameProperty() { return firstName; }
}
public void initialize(final URL arg0, final ResourceBundle arg1) {
Bindings.bindBidirectional(firstNameField.textProperty(), personWrapper.getProperty("firstName"));
}
Answer the question
In order to leave comments, you need to log in
Look here
https://ugate.wordpress.com/2012/06/06/javafx-pojo...
https://ugate.wordpress.com/2012/06/14/javafx-prog...
https:// ugate.wordpress.com/2012/07/30/javafx-prog...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question