forked from iluwatar/java-design-patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.java
23 lines (18 loc) · 826 Bytes
/
App.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package com.iluwatar.binding;
public class App {
public static void main(String[] args) {
ObservableProperty<String> observableProperty = new ObservableProperty<>("Initial Value");
TextView textView = new TextView();
// Bind TextView to ObservableProperty
observableProperty.addObserver(textView);
// Update ObservableProperty
System.out.println("Setting value in ObservableProperty...");
observableProperty.setValue("Hello, Design Patterns!");
// Simulate user input through TextView
System.out.println("User updates TextView...");
textView.setText("User Input!");
// Set another value in ObservableProperty to observe two-way binding
System.out.println("Setting another value in ObservableProperty...");
observableProperty.setValue("Two-Way Binding Works!");
}
}