cljfx 2021-10-17

should I expect setting a :style-class in a :cell-factory (in a table view in this case) to work? I'm not seeing them getting set properly right now. I'm led to believe JavaFX does allow individual cells to have their own classes.

I would expect style classes to work, can you share an example?

This works for me:

(require '[cljfx.css :as css]
         '[cljfx.api :as fx])

(def css-url
  (::css/url (css/register ::css {".red" {:-fx-text-fill :red}
                                  ".green" {:-fx-text-fill :green}})))

(fx/on-fx-thread
  (fx/create-component
    {:fx/type :stage
     :showing true
     :scene {:fx/type :scene
             :stylesheets [css-url]
             :root {:fx/type :table-view
                    :columns [{:fx/type :table-column
                               :cell-value-factory identity
                               :cell-factory {:fx/cell-type :table-cell
                                              :describe (fn [x]
                                                          {:text (str x)
                                                           :style-class (name x)})}}]
                    :items [:red :green]}}}))

Ahh, I'm setting it one level up alongside the cell type. That explains it, thanks!

👍 1