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: Java EE 7 Testing and Quality Workshop

A book about rethinking Java EE Patterns

Comments:

Ah, now i've got it :)

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

I hit a roadblock trying to change the Dynamic Web Module version to 2.5. Eclipse reports “cannot change version of project facet dynamic web module to 2.5″, nothing more.How do I change the facet to 2.5?

Posted by net grid on July 21, 2012 at 05:39 PM CEST #

An useful and an important one information to enable displaying data in data grid’s cells.its also an important one.

Posted by Annie on July 23, 2012 at 01:43 PM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
realworldpatterns.com
...the last 150 posts
...the last 10 comments
Links
License