5

I'm trying to use Swing from Clojure, and I'm getting confused by gen-class and I can't tell from the documentation if this is supposed to work - paintComponent is a protected method on JPanel, and I'm able to override it, but when I try to call the exposed superclass's method, I get java.lang.IllegalArgumentException: No matching method found: parentPaintComponent for class project.PicturePanel . Can anyone clarify why I don't seem to have access to this method?

(ns project.PicturePanel
  (:gen-class
    :extends javax.swing.JPanel
    :name project.PicturePanel
    :exposes-methods {paintComponent parentPaintComponent}))

(defn -paintComponent [this g]
  (println this)
  (println g)
  (.parentPaintComponent this g))
jes5199
  • 18,324
  • 12
  • 36
  • 40
  • 1
    Are you aware of seesaw? https://github.com/daveray/seesaw – Daniel Kaplan May 28 '13 at 19:06
  • I'll give seesaw a shot, but I sure would like to understand the Java interop stuff better. – jes5199 May 28 '13 at 22:56
  • 1
    Hmm, I just tested this and it worked perfect well for me. Can you provide more details about your project setup and calling code? Did you use AOT compilation? – A. Webb May 29 '13 at 00:58
  • A. Webb - thanks for the hint! It turns out that "lein run" was not recompiling the class, so I was in a funny state where the new paintComponent method was getting interpreted but the rest of the class was an old, out of date binary. After I re-ran "lein compile project.PicturePanel", things started working! – jes5199 May 29 '13 at 01:19

1 Answers1

2

Yes! The code works correctly if you make sure that your compiled .class files are up to date. Try recompiling them!

jes5199
  • 18,324
  • 12
  • 36
  • 40