Skip to content

Instantly share code, notes, and snippets.

@Kuchitama
Last active February 22, 2022 21:28
Show Gist options
  • Save Kuchitama/4572467 to your computer and use it in GitHub Desktop.
Save Kuchitama/4572467 to your computer and use it in GitHub Desktop.
JavaFX + Clojure + leiningen
(ns kuchitama.javafx
(:gen-class
:extends javafx.application.Application)
(:import [javafx.application Application]
[javafx.scene Scene Group]
[javafx.stage Stage StageBuilder]))
(defn -start [this stage]
(let [scene (Scene. (Group.))
builder (doto (StageBuilder/create)
(.title "test")
(.scene scene)
(.x 100)
(.y 100)
(.width 300)
(.height 200)
)]
(.show (.build builder))))
(defn -main [& args]
(Application/launch kuchitama.javafx args))
(defproject javafx "0.1.0-SNAPSHOT"
:description "Sample Program of JavaFX with Clojure"
:dependencies [[org.clojure/clojure "1.4.0"]]
:resource-paths ["lib/jfxrt.jar"]
:main kuchitama.javafx
)
@jzwolak
Copy link

jzwolak commented Feb 22, 2022

Include the Gluon JavaFX maven artifacts and then use as usual.

Something like:

                 [org.openjfx/javafx-base "11.0.2"]
                 [org.openjfx/javafx-controls "11.0.2"]
                 [org.openjfx/javafx-graphics "11.0.2"]
                 [org.openjfx/javafx-swing "11.0.2"]

Note, the *Builder classes have been removed (a long time ago). This bit me as I had an old project that depended on them and could not find them.

@jzwolak
Copy link

jzwolak commented Feb 22, 2022

There are Gluon JavaFX maven artifacts for JDK 17 as well. I use JDK 11 for a legacy application because JDK 11 will still be supported for another year and a half or so. Same with the Gluon JavaFX jars.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment