Skip to content

Instantly share code, notes, and snippets.

@polypus74
Created August 15, 2010 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save polypus74/525124 to your computer and use it in GitHub Desktop.
Save polypus74/525124 to your computer and use it in GitHub Desktop.
import org.jfxtras.lang.XBind;
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.layout.HBox;
import javafx.scene.control.*;
function run():Void {
try {
def lab = Label { text: "->" };
def ctx = javafx.reflect.FXLocal.getContext();
def labMirror = ctx.mirrorOf(lab);
def x = XBind.bindTo(labMirror, labMirror.getType().getVariable("text"));
// if i comment this label out then the listener is not called
Label { text: bind x.ref as String; }
x.addListener(function(x:Object, y:Object):Void { Alert.inform("changed") });
Stage {
scene: Scene {
content: HBox {
content: [
Button {
text: "->"
action: function():Void {
lab.text = "{lab.text} ->";
}
},
lab
]
}
}
}
} catch (x: java.lang.Exception) {
Alert.inform("{x}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment