This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-03
Channels
- # announcements (8)
- # aws (2)
- # babashka (16)
- # beginners (173)
- # calva (13)
- # cider (4)
- # cljfx (6)
- # cljs-dev (108)
- # clojure (63)
- # clojure-australia (2)
- # clojure-dev (10)
- # clojure-europe (73)
- # clojure-italy (8)
- # clojure-nl (4)
- # clojure-norway (5)
- # clojure-uk (4)
- # clojurescript (49)
- # clojureverse-ops (4)
- # community-development (3)
- # core-async (23)
- # cursive (3)
- # data-science (5)
- # datomic (25)
- # emacs (3)
- # events (1)
- # fulcro (13)
- # helix (5)
- # introduce-yourself (1)
- # lein-figwheel (1)
- # lsp (36)
- # malli (1)
- # meander (2)
- # membrane (4)
- # music (8)
- # nextjournal (51)
- # off-topic (47)
- # other-languages (5)
- # pathom (31)
- # pedestal (5)
- # planck (14)
- # polylith (5)
- # portal (1)
- # re-frame (30)
- # react (2)
- # reagent (24)
- # releases (1)
- # rewrite-clj (18)
- # ring (9)
- # sci (33)
- # shadow-cljs (49)
- # testing (3)
- # tools-build (21)
- # tools-deps (29)
- # vim (19)
- # web-security (1)
- # xtdb (12)
Does anyone know of a cljfx example that renders an image from a resources directory?
if you use (
to get a url, you can pass that to something like https://github.com/phronmophobic/membrane/blob/master/src/membrane/cljfx.clj#L54 to create an javafx.scene.image.Image. You can then draw the image like https://github.com/phronmophobic/membrane/blob/master/src/membrane/cljfx.clj#L571
Here: https://clojurians.slack.com/archives/CGHHJNENB/p1589214377102900 @vlaaad mentions the :image prop of :fx/type :image-view can load resources from the class path. When I set the :url prop value to (http://clojure.java.io/resource "logo.png") I get this exception java.lang.ClassCastException: class java.net.URL cannot be cast to class java.lang.String (java.net.URL and java.lang.String are in module java.base of loader 'bootstrap').
(defn resource-image [{:keys [resource-file]}]
{:fx/type :image-view
:image (str ( resource-file))})
If you're deploying as a jar, it might be worth double checking if it still works when you jar your application. There are sometimes differences in behavior between file based resources and resources included in the jar.