Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
27 lines (14 sloc) 1.84 KB
Very Simple JavaFX application that talks to Clojure.
Overview
The layers are 1) JavaFX UI 2) Java Facade class for the Clojure function 3) Clojure class exposing one function.
It has the following UI components:
Slider - bound to 'result'
Button - calls a method on a Java class that is a facade for a clojure function that prints the value then returns it back to the caller.
TextField - bound to result.
Detail
The only component in the UI that calls Clojure is the button. The button calls the method on the Java facade class, which then envokes a Clojure function in a Clojure script that was loaded upon the instanciation of the Java facade class. The Clojure function, prints to console, then returns the value that it was invoked with to the Java facade, which then returns it to the JavaFX UI. Since the value is bound, the othe UI widgets that are bound to 'result' also update. NOTE: The slider and textfield do not call down to the clojure code even though they are bound to result.
Summary
This is the simplest version of anything I could think of for connecting JavaFX to Clojure. I want to work on a version of the Clojure code that will auto-generate the Java facade class. At this point though, I'm not sure I even need that. I think the classes that are generated by compiling the Clojure functions with the gen-class option on for the file would work, but I'm so new to Clojure I've not had much time to work thru that understanding.
I originially wrote this on June 26 of 2009 and posted about it on the Clojure Google group, but work and life got in the way and I'm only just back to it now and instead of letting it languish anymore, I'm putting it up on Github. If anyone finds if useful, let me know by posting back to the Github site and/or giving me a mention on your blog or software.
Thanks and happy Clojuring and JavaFXing!
Sam Griffith Jr