Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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))
like image 674
jes5199 Avatar asked Nov 03 '22 21:11

jes5199


1 Answers

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

like image 147
jes5199 Avatar answered Nov 12 '22 23:11

jes5199