简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM