Elementary question about displaying images in an app

52 views
Skip to first unread message

Christopher Howard

unread,
Apr 24, 2014, 2:39:12 PM4/24/14
to clojure
This is, I think, as much of a Java question as a Clojure question
(I'm learning both at the same time). I'm writing a small desktop
application, and I need to paint a few images in one part of the
window (contained in PNGs). I'm looking through AWT/Swing/Graphics2D
documentation, but I am a little unclear about the correct/modern way
of doing this.

Is Canvas the component I need? If so, how do I subclass it and
override the paint method (from within Clojure). Or is there a better
way to approach this?

Niels van Klaveren

unread,
Apr 24, 2014, 5:40:27 PM4/24/14
to clo...@googlegroups.com
The best way to use Swing from Clojure is the seesaw library. It managed to clojurize Swing remarkably well, and is trying it's hardest to get all glaring inconsistencies out of swing use.
Simple example to set a background for a frame:

(
frame
   
:title "Hello"
    :content (label :icon (clojure.java.io/file image)))
Reply all
Reply to author
Forward
0 new messages