0

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.

Daniel Ziltener
  • 647
  • 1
  • 6
  • 21
  • Not sure about your specific problem, but you may be interested in this version: https://github.com/fn-fx/fn-fx – Alan Thompson Oct 13 '18 at 18:05
  • Also this question may have relevance: https://stackoverflow.com/questions/12984310/javafx-response-to-swingutilities-invokelater – Alan Thompson Oct 13 '18 at 18:07
  • `runLater` doesn't help. It's not even necessary at that point, since `start` gets called on the event thread to begin with (otherwise, neiter `setScene` nor `show` would work). – Daniel Ziltener Oct 14 '18 at 22:51

0 Answers0