Search code examples
imageuser-interfacebackgroundclojureseesaw

How to set an image for the panel background with seesaw?


I want to set a custom image for the panel background in my clojure app. Using seesaw I can set some color for the background:

(defn make-panel []
      (border-panel
        :north (flow-panel :align :center
                           :items [(label :text "TEXT")])
        :center (canvas :class :board
                        :background :black)
        :border 5))

but how to choose an image using its url?


Solution

  • Seesaw lets you use an image for frame content, via the icon function (now in seesaw.icon), like so:

    (frame :title "Hola!"
           ; ....
           :content (label :icon img_bg)
    

    where img_bg is a File, URL, etc. However, looking at the Seesaw code, I don't see a way to put a background image directly in a panel through the Seesaw API. You may have to drop down to Java interop and use the Swing API directly. This SO question would suggest that it's possible, and may get you started.