Set the css styles of a JavaFX app in Clojure

I was looking in the web for a quick way to be working with the css styles of my JavaFx app in Clojure,make modifications in my CSS file and update the UI instantly so it is nice and quick way to work.

But I could not find any straight way to do it so that I have cooked my own:


(ns your.namespace
   (:require [[clojure.java.io :as io]]))

   (run-now (doto (.getStylesheets my-scene)
               .clear
               (.add (.toExternalForm (io/resource "standard.css")))))


;You could also use 'javafx.application.Platform/runLater' instead of 'run-now'

You will easily find in the web the macro “run-now”.
I have placed the file “standard.css” in the “resources” folder of my Leiningen project.

I am working with the library clojurefx, I hope I can make some improvements and be adding more features into it if my pull requests are accepted 😉

Leave a Reply

Your email address will not be published. Required fields are marked *

*