Home

License Clojars Liberapay receiving Flattr this

ClojureFX

Clojars project

A Clojure extension to make working with JavaFX simpler and more idiomatic. It allows you to naturally work with stock JavaFX components through use of extended protocols. Should a feature be missing you can easily extend ClojureFX in your own codebase or just fall back to standard JavaFX methods.

Next stable release

Next stable release is planned for December 2018.

Features

Take a look at the ClojureFX Manual.

FXML loading and controller generation


(require '[clojurefx.fxml :as fxml])

(defn stage-init [instance] ;; Every function called from JavaFX gets handed the controller instance.
    nil)

(def maincontent (fxml/load-fxml-with-controller (io/resource "fxml/mainwindow.fxml") ;; Load an FXML file
                                                 'example.core/stage-init))           ;; and define the namespace and init function.

Declarative UI programming


(def superbutton (compile [Button {:text "Close"
                                   :action #'close-handler}]))

(compile [VBox {:id "TopLevelVBox"
                :children [Label {:text "Hi!"}
                           Label {:text "I'm ClojureFX!"}
                           HBox {:id "HorizontalBox"
                           :children [Button {:text "OK"}
						              superbutton]}]}])