Adding fields to a proxied class in Clojure

Posted by mikera on Stack Overflow See other posts from Stack Overflow or by mikera
Published on 2010-06-16T20:45:36Z Indexed on 2010/06/16 21:02 UTC
Read the original article Hit count: 178

Filed under:
|
|
|
|

I'm using "proxy" to extend various Swing classes in a Clojure GUI application, generally with code that looks something like:

(def ^JPanel mypanel 
  (proxy [JPanel] []
    (paintComponent [#^Graphics g]
      (.drawImage g background-image 0 0 nil))))

This works well but I can't figure out how to add additional fields to the newly extended class, for example making the background-image a field that could be subsequently updated. This would be pretty easy and common practice in Java.

Is there a good way to do this in Clojure? Or is there another preferred method to achieve the same effect?

© Stack Overflow or respective owner

Related posts about java

Related posts about swing