fn-fx / fn-fx

A Functional API around JavaFX / OpenJFX.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to start with a fxml file from SceneBuilder?

andrenventer opened this issue · comments

It is...

(ns asiago-fx.core
  (:require [fn-fx.fx-dom :as dom]
            [fn-fx.controls :as ui]
            [fn-fx.diff :refer [component defui render should-update?]]
            [clojure.java.io :as io]
            [clojure.tools.logging :as log])
  (:import (javafx.fxml FXMLLoader)
           (javafx.scene Scene)))

(defn -main []
  (let [df (io/resource "main-app.fxml")
        l (log/debug df)
        s (.load (FXMLLoader.) (io/input-stream df))
        scene (Scene. s)
        u (ui/stage
            :title "Hello World!"
            :shown true
            :min-width 500
            :min-height 300
            :scene scene)

        handler-fn (fn [evt]
                     (println "Received Event: " evt))]


    (dom/app u handler-fn)))


;(-main)

In the scene builder inside IntelliJ it's possible to specify a "controller" that gets run when the button is clicked but on import I get:

Execution error (LoadException) at javafx.fxml.FXMLLoader/constructLoadException (FXMLLoader.java:2621).
No controller specified.
unknown path:8

Is there a way to hook up controllers? Or another approach for triggering Clojure code from UI events?