JavaFX: RemoteTextDocument
JavaFX is still undergoing changes. Hopefully the SDK & API will become solidified soon. Right now it is pretty bleeding edge, with incomplete Javadoc. Not a criticism, just the facts.
I wanted to see how hard it was to use the RemoteTextDocument API to pull in some sort of webservice feed. Turns out it is not so hard once you know how to do it. Since there appears to be no existing examples of this out there, here’s a snippet of code that could be useful.
import javafx.async.*;
var remoteTextDocument:RemoteTextDocument = RemoteTextDocument {
url: "http://api.flickr.com/services/feeds/photos_public.gne";
}
var doc:String = bind remoteTextDocument.document on replace {
if (remoteTextDocument.done)
java.lang.System.out.println("doc = {doc}");
}
All this does is immediately fetch the contents of the Flickr URL, and print it to the console. I would say this is pretty nice. I was able to incorporate the concept shown above into a small application that shows a thumbnail photo feed without a lot of code.
As of this post, this is only working with the nightly trunk build of the compiler. You’ll get a NegativeArraySizeException running it in Netbeans since their plugin is not being built off the trunk.
I have a corresponding post on the OpenJFX forums about this issue.
It seems that that the RemoteTextDocument has been removed from JavaFX (at least from the version I have which is 1.7).
Mcihael Behrens
July 4, 2009 at 12:21 pm