Adam Bien's Weblog

Friday Dec 23, 2011

Java FX 2 Data Binding Explained …With A JUnit Test


import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import org.junit.Test;

public class StringDataBindingTest {
    
    @Test
    public void bindUnidirectionally(){
        String expected = "DukeFX";
        StringProperty from = new SimpleStringProperty();
        StringProperty to = new SimpleStringProperty();
        to.bind(from);
        from.set(expected);
        String actual = to.get();
        assertThat(actual,is(expected));
    }
}

Any questions? :-)



*NEW* Workshop: "Real World Java EE 6/7 Bootstrap" and book: Real World Java EE Night Hacks--Dissecting the Business Tier

Comments:

Ah, now i've got it :)

Posted by Mike on December 23, 2011 at 09:41 AM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
Meta
My Recent Book
Java One 2009/2011
...the last 150 posts
...the last 10 comments
Links
License