jes5199
jes5199

Reputation: 18913

Can gen-class override a protected Java method?

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))

Upvotes: 5

Views: 822

Answers (1)

jes5199
jes5199

Reputation: 18913

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

Upvotes: 2

Related Questions