I have my main namespace inserted below; when I run ./gradlew run
, it will run fine only if I comment out the primary-screen (.getPrimary Screen)
line, so this seems to be broken for whatever reason?
(ns lyrion.cec
(:gen-class)
(:require [clojurefx.clojurefx :as fx])
(:import (javafx.stage Stage Screen)
(javafx.scene Scene)
(javafx.scene.control Label)
(javafx.geometry Rectangle2D)))
(defn init []
nil)
(defn start [^Stage stage]
(let [content ^Label (Label. "Hello World")
primary-screen (.getPrimary Screen)
;;visual-bounds ^Rectangle2D (.getVisualBounds ^Screen primary-screen)
;;scene ^Scene (Scene. content (.getWidth visual-bounds) (.getHeight visual-bounds))
scene ^Scene (Scene. content 800 600)]
(.setScene stage scene)
(.show stage)))
(defn stop []
nil)
(defn -main
""
[& args]
(fx/start-app init start stop))
fx/start-app
is a function of my clojurefx library that creates an Application
subclass and calls init, start and stop accordingly as per specification. I never had a problem with that so far in any desktop JavaFX application. It is also weird that apparently, doing this myself is necessary in JavaFXPorts even though all examples suggest otherwise.